Completed
Pull Request — master (#2)
by Jimmy
1075:13 queued 1053:53
created
includes/librairies/eav/attributes_set.class.php 4 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,6 +45,7 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	*	Get the url listing slug of the current class
47 47
 	*
48
+	*	@param string $message
48 49
 	*	@return string The table of the class
49 50
 	*/
50 51
 	function setMessage($message){
@@ -665,7 +666,7 @@  discard block
 block discarded – undo
665 666
 	/**
666 667
 	*	Display inteface allowing to manage the attribute set and group details
667 668
 	*
668
-	*	@param object $atributeSetId The element's identifier we have to manage the details for
669
+	*	@param object $attributeSetId The element's identifier we have to manage the details for
669 670
 	*
670 671
 	*	@return string $attributeSetDetailsManagement The html output of management interface
671 672
 	*/
@@ -949,7 +950,7 @@  discard block
 block discarded – undo
949 950
 	*	@param integer $attributeSetId The attribute set identifier we want to get the details for
950 951
 	*	@param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on
951 952
 	*
952
-	*	@return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set
953
+	*	@return string $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set
953 954
 	*/
954 955
 	public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){
955 956
 		global $wpdb, $validAttributeList;
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -43,42 +43,42 @@  discard block
 block discarded – undo
43 43
 	public $pageMessage = '';
44 44
 
45 45
 	/**
46
-	*	Get the url listing slug of the current class
47
-	*
48
-	*	@return string The table of the class
49
-	*/
46
+	 *	Get the url listing slug of the current class
47
+	 *
48
+	 *	@return string The table of the class
49
+	 */
50 50
 	function setMessage($message){
51 51
 		$this->pageMessage = $message;
52 52
 	}
53 53
 	/**
54
-	*	Get the url listing slug of the current class
55
-	*
56
-	*	@return string The table of the class
57
-	*/
54
+	 *	Get the url listing slug of the current class
55
+	 *
56
+	 *	@return string The table of the class
57
+	 */
58 58
 	function getListingSlug(){
59 59
 		return self::urlSlugListing;
60 60
 	}
61 61
 	/**
62
-	*	Get the url edition slug of the current class
63
-	*
64
-	*	@return string The table of the class
65
-	*/
62
+	 *	Get the url edition slug of the current class
63
+	 *
64
+	 *	@return string The table of the class
65
+	 */
66 66
 	public static function getEditionSlug(){
67 67
 		return self::urlSlugEdition;
68 68
 	}
69 69
 	/**
70
-	*	Get the database table of the current class
71
-	*
72
-	*	@return string The table of the class
73
-	*/
70
+	 *	Get the database table of the current class
71
+	 *
72
+	 *	@return string The table of the class
73
+	 */
74 74
 	public static function getDbTable(){
75 75
 		return self::dbTable;
76 76
 	}
77 77
 	/**
78
-	*	Define the title of the page
79
-	*
80
-	*	@return string $title The title of the page looking at the environnement
81
-	*/
78
+	 *	Define the title of the page
79
+	 *
80
+	 *	@return string $title The title of the page looking at the environnement
81
+	 */
82 82
 	function pageTitle(){
83 83
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : '';
84 84
 		$objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : '';
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	*	Define the different message and action after an action is send through the element interface
100
-	*/
99
+	 *	Define the different message and action after an action is send through the element interface
100
+	 */
101 101
 	function elementAction(){
102 102
 		global $wpdb, $initialEavData;
103 103
 		$pageMessage = $actionResult = '';
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 		self::setMessage($pageMessage);
356 356
 	}
357 357
 	/**
358
-	*	Return the list page content, containing the table that present the item list
359
-	*
360
-	*	@return string $listItemOutput The html code that output the item list
361
-	*/
358
+	 *	Return the list page content, containing the table that present the item list
359
+	 *
360
+	 *	@return string $listItemOutput The html code that output the item list
361
+	 */
362 362
 	function elementList() {
363
-	    //Create an instance of our package class...
364
-	    $wpshop_list_table = new wpshop_attributes_set_custom_List_table();
365
-	    //Fetch, prepare, sort, and filter our data...
363
+		//Create an instance of our package class...
364
+		$wpshop_list_table = new wpshop_attributes_set_custom_List_table();
365
+		//Fetch, prepare, sort, and filter our data...
366 366
 		$status="'valid', 'moderated'";
367 367
 		$attribute_set_list = array();
368 368
 		if(!empty($_REQUEST['attribute_groups_status'])){
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	}
424 424
 
425 425
 	/**
426
-	*	Return the page content to add a new item
427
-	*
428
-	*	@return string The html code that output the interface for adding a nem item
429
-	*/
426
+	 *	Return the page content to add a new item
427
+	 *
428
+	 *	@return string The html code that output the interface for adding a nem item
429
+	 */
430 430
 	function elementEdition($itemToEdit = '') {
431 431
 		global $attribute_hidden_field;
432 432
 
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
 		return $the_form;
575 575
 	}
576 576
 	/**
577
-	*	Return the different button to save the item currently being added or edited
578
-	*
579
-	*	@return string $currentPageButton The html output code with the different button to add to the interface
580
-	*/
577
+	 *	Return the different button to save the item currently being added or edited
578
+	 *
579
+	 *	@return string $currentPageButton The html output code with the different button to add to the interface
580
+	 */
581 581
 	function getPageFormButton($element_id = 0){
582 582
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add';
583 583
 		$currentPageButton = '';
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 	}
587 587
 
588 588
 	/**
589
-	*	Get the existing element list into database
590
-	*
591
-	*	@param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned
592
-	*	@param string $elementStatus optionnal The status of element to get into database. Default is set to valid element
593
-	*
594
-	*	@return object $elements A wordpress database object containing the element list
595
-	*/
589
+	 *	Get the existing element list into database
590
+	 *
591
+	 *	@param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned
592
+	 *	@param string $elementStatus optionnal The status of element to get into database. Default is set to valid element
593
+	 *
594
+	 *	@return object $elements A wordpress database object containing the element list
595
+	 */
596 596
 	public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){
597 597
 		global $wpdb;
598 598
 		$elements = array();
@@ -663,12 +663,12 @@  discard block
 block discarded – undo
663 663
 	}
664 664
 
665 665
 	/**
666
-	*	Display inteface allowing to manage the attribute set and group details
667
-	*
668
-	*	@param object $atributeSetId The element's identifier we have to manage the details for
669
-	*
670
-	*	@return string $attributeSetDetailsManagement The html output of management interface
671
-	*/
666
+	 *	Display inteface allowing to manage the attribute set and group details
667
+	 *
668
+	 *	@param object $atributeSetId The element's identifier we have to manage the details for
669
+	 *
670
+	 *	@return string $attributeSetDetailsManagement The html output of management interface
671
+	 */
672 672
 	public static function attributeSetDetailsManagement($attributeSetId = ''){
673 673
 		global $validAttributeList; global $wpdb;
674 674
 		$user_more_script = $add_button = '';
@@ -944,13 +944,13 @@  discard block
 block discarded – undo
944 944
 	}
945 945
 
946 946
 	/**
947
-	*	Get the complete details about attributes sets
948
-	*
949
-	*	@param integer $attributeSetId The attribute set identifier we want to get the details for
950
-	*	@param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on
951
-	*
952
-	*	@return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set
953
-	*/
947
+	 *	Get the complete details about attributes sets
948
+	 *
949
+	 *	@param integer $attributeSetId The attribute set identifier we want to get the details for
950
+	 *	@param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on
951
+	 *
952
+	 *	@return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set
953
+	 */
954 954
 	public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){
955 955
 		global $wpdb, $validAttributeList;
956 956
 		$attributeSetDetailsGroups = '';
@@ -1002,12 +1002,12 @@  discard block
 block discarded – undo
1002 1002
 	}
1003 1003
 
1004 1004
 	/**
1005
-	*	Get the attribute list of attribute not associated to he set we are editing
1006
-	*
1007
-	*	@param integer $attributeSetId The attribute set identifier we want to get the details for
1008
-	*
1009
-	*	@return array $attributeSetDetails The List of attribute not affected
1010
-	*/
1005
+	 *	Get the attribute list of attribute not associated to he set we are editing
1006
+	 *
1007
+	 *	@param integer $attributeSetId The attribute set identifier we want to get the details for
1008
+	 *
1009
+	 *	@return array $attributeSetDetails The List of attribute not affected
1010
+	 */
1011 1011
 	public static function get_not_affected_attribute($attributeSetId, $entity_set_id){
1012 1012
 		global $wpdb;
1013 1013
 
@@ -1042,12 +1042,12 @@  discard block
 block discarded – undo
1042 1042
 	}
1043 1043
 
1044 1044
 	/**
1045
-	*	Get the existing attribute set for an entity
1046
-	*
1047
-	*	@param integer $entityId The entity identifier we want to get the entity set list for
1048
-	*
1049
-	*	@return object $entitySets The entity sets list for the given entity
1050
-	*/
1045
+	 *	Get the existing attribute set for an entity
1046
+	 *
1047
+	 *	@param integer $entityId The entity identifier we want to get the entity set list for
1048
+	 *
1049
+	 *	@return object $entitySets The entity sets list for the given entity
1050
+	 */
1051 1051
 	public static function get_attribute_set_list_for_entity($entityId){
1052 1052
 		global $wpdb;
1053 1053
 		$entitySetList = '';
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
 	}
1065 1065
 
1066 1066
 	/**
1067
-	* Traduit le shortcode et affiche un groupe d'attributs
1068
-	* @param array $atts : tableau de param�tre du shortcode
1069
-	* @return mixed
1070
-	**/
1067
+	 * Traduit le shortcode et affiche un groupe d'attributs
1068
+	 * @param array $atts : tableau de param�tre du shortcode
1069
+	 * @return mixed
1070
+	 **/
1071 1071
 	function wpshop_att_group_func($atts) {
1072 1072
 		global $wpdb;
1073 1073
 
Please login to merge, or discard this patch.
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 * @package wpshop
22 22
 * @subpackage librairies
23 23
 */
24
-class wpshop_attributes_set{
24
+class wpshop_attributes_set {
25 25
 	/*	Define the database table used in the current class	*/
26 26
 	const dbTable = WPSHOP_DBT_ATTRIBUTE_SET;
27 27
 	/*	Define the url listing slug used in the current class	*/
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	*
48 48
 	*	@return string The table of the class
49 49
 	*/
50
-	function setMessage($message){
50
+	function setMessage($message) {
51 51
 		$this->pageMessage = $message;
52 52
 	}
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	*
56 56
 	*	@return string The table of the class
57 57
 	*/
58
-	function getListingSlug(){
58
+	function getListingSlug() {
59 59
 		return self::urlSlugListing;
60 60
 	}
61 61
 	/**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	*
64 64
 	*	@return string The table of the class
65 65
 	*/
66
-	public static function getEditionSlug(){
66
+	public static function getEditionSlug() {
67 67
 		return self::urlSlugEdition;
68 68
 	}
69 69
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	*
72 72
 	*	@return string The table of the class
73 73
 	*/
74
-	public static function getDbTable(){
74
+	public static function getDbTable() {
75 75
 		return self::dbTable;
76 76
 	}
77 77
 	/**
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 	*
80 80
 	*	@return string $title The title of the page looking at the environnement
81 81
 	*/
82
-	function pageTitle(){
82
+	function pageTitle() {
83 83
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
84 84
 		$objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : '';
85 85
 
86
-		$title = __(self::pageTitle, 'wpshop' );
87
-		if($action != ''){
88
-			if($action == 'edit'){
86
+		$title = __(self::pageTitle, 'wpshop');
87
+		if ($action != '') {
88
+			if ($action == 'edit') {
89 89
 				$editedItem = self::getElement($objectInEdition);
90 90
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop'));
91 91
 			}
92
-			elseif($action == 'add')
92
+			elseif ($action == 'add')
93 93
 				$title = __(self::pageAddingTitle, 'wpshop');
94 94
 		}
95 95
 		return $title;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	*	Define the different message and action after an action is send through the element interface
100 100
 	*/
101
-	function elementAction(){
101
+	function elementAction() {
102 102
 		global $wpdb, $initialEavData;
103 103
 		$pageMessage = $actionResult = '';
104 104
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 		/****************************************************************************/
108 108
 		$saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : '';
109 109
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add';
110
-		if(!empty($action) && ($action=='activate') && (!empty($_REQUEST['id']))){
110
+		if (!empty($action) && ($action == 'activate') && (!empty($_REQUEST['id']))) {
111 111
 			$query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>sanitize_key($_REQUEST['id'])));
112 112
 			wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . sanitize_key($_REQUEST['id'])));
113 113
 		}
114
-		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
114
+		if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) {
115 115
 			$editedElement = self::getElement($saveditem);
116 116
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>');
117 117
 		}
118
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
118
+		elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) {
119 119
 			$editedElement = self::getElement($saveditem, "'deleted'");
120 120
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>');
121 121
 		}
@@ -123,61 +123,61 @@  discard block
 block discarded – undo
123 123
 		/*	Define the database operation type from action launched by the user	 */
124 124
 		/*************************			GENERIC				****************************/
125 125
 		/*************************************************************************/
126
-		$attribute_set_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array();
127
-		$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : '');
126
+		$attribute_set_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array();
127
+		$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : '');
128 128
 		$id = isset($attribute_set_parameter['id']) ? sanitize_key($attribute_set_parameter['id']) : ((!empty($_GET['id'])) ? sanitize_key($_GET['id']) : '');
129 129
 		$set_section = !empty($attribute_set_parameter['set_section']) ? sanitize_text_field($attribute_set_parameter['set_section']) : '';
130 130
 		unset($attribute_set_parameter['set_section']);
131 131
 
132 132
 		/*	Specific case for the attribute groups	*/
133
-		if(!isset($attribute_set_parameter['status'])){
133
+		if (!isset($attribute_set_parameter['status'])) {
134 134
 			$attribute_set_parameter['status'] = 'moderated';
135 135
 		}
136
-		if(!isset($attribute_set_parameter['default_set'])){
136
+		if (!isset($attribute_set_parameter['default_set'])) {
137 137
 			$attribute_set_parameter['default_set'] = 'no';
138 138
 		}
139 139
 
140
-		if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))){
141
-			if(current_user_can('wpshop_edit_attribute_set')){
140
+		if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))) {
141
+			if (current_user_can('wpshop_edit_attribute_set')) {
142 142
 				$attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s');
143
-				if($pageAction == 'delete'){
144
-					if(current_user_can('wpshop_delete_attribute_set'))
143
+				if ($pageAction == 'delete') {
144
+					if (current_user_can('wpshop_delete_attribute_set'))
145 145
 						$attribute_set_parameter['status'] = 'deleted';
146 146
 					else
147 147
 						$actionResult = 'userNotAllowedForActionDelete';
148 148
 				}
149 149
 				$actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable());
150 150
 			}
151
-			else{
151
+			else {
152 152
 				$actionResult = 'userNotAllowedForActionEdit';
153 153
 			}
154 154
 
155 155
 			/** Address display managment **/
156
-				if ( !empty($_REQUEST['id']) ) {
156
+				if (!empty($_REQUEST['id'])) {
157 157
 					$is_billing = $is_shipping = false;
158 158
 					/** Get billing option **/
159
-					$billing_option = get_option( 'wpshop_billing_address' );
160
-					$shipping_option = get_option( 'wpshop_shipping_address_choice' );
159
+					$billing_option = get_option('wpshop_billing_address');
160
+					$shipping_option = get_option('wpshop_shipping_address_choice');
161 161
 
162
-					if( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $_REQUEST['id'] ) {
162
+					if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $_REQUEST['id']) {
163 163
 						$is_billing = true;
164 164
 					}
165 165
 
166
-					if( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $_REQUEST['id'] ) {
166
+					if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $_REQUEST['id']) {
167 167
 						$is_shipping = true;
168 168
 					}
169 169
 
170 170
 					$attribute_display = array();
171
-					if ( !empty($_REQUEST['attribute_group_order']) && $attribute_group_order = (array) $_REQUEST['attribute_group_order'] ) {
171
+					if (!empty($_REQUEST['attribute_group_order']) && $attribute_group_order = (array)$_REQUEST['attribute_group_order']) {
172 172
 
173
-						foreach( $attribute_group_order as $group_id => $group_def ) {
173
+						foreach ($attribute_group_order as $group_id => $group_def) {
174 174
 							$end_line_element_id = 0;
175
-							if( $group_id != 'newOrderNotAffectedAttribute' ) {
176
-								$attribute_display[ str_replace('newOrder', '', $group_id) ] = explode( ',', $group_def );
175
+							if ($group_id != 'newOrderNotAffectedAttribute') {
176
+								$attribute_display[str_replace('newOrder', '', $group_id)] = explode(',', $group_def);
177 177
 
178
-								foreach( $attribute_display[ str_replace('newOrder', '', $group_id) ] as $att_id => $att ) {
179
-									if( $att == 'wps-attribute-end-line' ) {
180
-										$attribute_display[ str_replace('newOrder', '', $group_id) ][$att_id] = 'wps-attribute-end-line-'.$end_line_element_id;
178
+								foreach ($attribute_display[str_replace('newOrder', '', $group_id)] as $att_id => $att) {
179
+									if ($att == 'wps-attribute-end-line') {
180
+										$attribute_display[str_replace('newOrder', '', $group_id)][$att_id] = 'wps-attribute-end-line-' . $end_line_element_id;
181 181
 										$end_line_element_id++;
182 182
 									}
183 183
 								}
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 					}
188 188
 
189 189
 
190
-					if ( $is_billing && !$is_shipping ) {
190
+					if ($is_billing && !$is_shipping) {
191 191
 						$billing_option['display_model'] = $attribute_display;
192
-						update_option( 'wpshop_billing_address', $billing_option );
192
+						update_option('wpshop_billing_address', $billing_option);
193 193
 					}
194 194
 
195
-					if ( !$is_billing && $is_shipping ) {
195
+					if (!$is_billing && $is_shipping) {
196 196
 						$shipping_option['display_model'] = $attribute_display;
197
-						update_option( 'wpshop_shipping_address_choice', $shipping_option );
197
+						update_option('wpshop_shipping_address_choice', $shipping_option);
198 198
 					}
199 199
 
200 200
 				}
201 201
 
202 202
 		}
203
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
204
-			if(current_user_can('wpshop_delete_attribute_set')){
203
+		elseif (($pageAction != '') && (($pageAction == 'delete'))) {
204
+			if (current_user_can('wpshop_delete_attribute_set')) {
205 205
 				$attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s');
206 206
 				$attribute_set_parameter['status'] = 'deleted';
207 207
 				$actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable());
@@ -209,32 +209,32 @@  discard block
 block discarded – undo
209 209
 			else
210 210
 				$actionResult = 'userNotAllowedForActionDelete';
211 211
 		}
212
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
213
-			if(current_user_can('wpshop_add_attribute_set')){
212
+		elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) {
213
+			if (current_user_can('wpshop_add_attribute_set')) {
214 214
 				$attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s');
215 215
 				$actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable());
216 216
 				$id = $wpdb->insert_id;
217
-				if ( empty( $set_section ) ) {
218
-					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'general',  'default_group' => 'yes', 'name' => __('Main information', 'wpshop')));
217
+				if (empty($set_section)) {
218
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'general', 'default_group' => 'yes', 'name' => __('Main information', 'wpshop')));
219 219
 
220 220
 					$selected_entity_query = $wpdb->prepare("SELECT post_name FROM " . $wpdb->posts . " WHERE ID = %d", $attribute_set_parameter['entity_id']);
221 221
 					if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT == $wpdb->get_var($selected_entity_query)) {
222
-						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'prices',  'default_group' => 'no', 'name' => __('Prices', 'wpshop')));
222
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'prices', 'default_group' => 'no', 'name' => __('Prices', 'wpshop')));
223 223
 						$price_attribute_set_id = $wpdb->insert_id;
224 224
 						$price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES);
225 225
 						unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]);
226
-						foreach($price_tab as $price_code){
226
+						foreach ($price_tab as $price_code) {
227 227
 							$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $price_code);
228 228
 							$attribute_id = $wpdb->get_var($query);
229
-							switch($price_code){
229
+							switch ($price_code) {
230 230
 								case WPSHOP_PRODUCT_PRICE_HT:
231
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 1 : 3;
231
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 1 : 3;
232 232
 									break;
233 233
 								case WPSHOP_PRODUCT_PRICE_TAX:
234 234
 										$position = 2;
235 235
 									break;
236 236
 								case WPSHOP_PRODUCT_PRICE_TTC:
237
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 3 : 1;
237
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 3 : 1;
238 238
 									break;
239 239
 								case WPSHOP_PRODUCT_PRICE_TAX_AMOUNT:
240 240
 										$position = 4;
@@ -253,44 +253,44 @@  discard block
 block discarded – undo
253 253
 		/************		CHANGE THE FIELD NAME TO TAKE TO DISPLAY				*************/
254 254
 		/************		CHANGE ERROR MESSAGE FOR SPECIFIC CASE					*************/
255 255
 		/****************************************************************************/
256
-		if($actionResult != ''){
256
+		if ($actionResult != '') {
257 257
 			$elementIdentifierForMessage = __('the attribute group', 'wpshop');
258
-			if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>';
259
-			if($actionResult == 'error'){/*	CHANGE HERE FOR SPECIFIC CASE	*/
258
+			if (!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>';
259
+			if ($actionResult == 'error') {/*	CHANGE HERE FOR SPECIFIC CASE	*/
260 260
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage);
261 261
 			}
262
-			elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){
262
+			elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {
263 263
 				/*****************************************************************************************************************/
264 264
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				******************/
265 265
 				/*****************************************************************************************************************/
266
-				if ( !empty($_REQUEST['wpshop_attribute_set_section_order']) ) {
266
+				if (!empty($_REQUEST['wpshop_attribute_set_section_order'])) {
267 267
 					$newOrder = str_replace('attribute_group_', '', sanitize_key($_REQUEST['wpshop_attribute_set_section_order']));
268 268
 					$order = explode(',', $newOrder);
269
-					foreach($order as $position => $set_section_id){
270
-						$_REQUEST['wpshop_attribute_set_section'][$set_section_id]['position']=$position;
269
+					foreach ($order as $position => $set_section_id) {
270
+						$_REQUEST['wpshop_attribute_set_section'][$set_section_id]['position'] = $position;
271 271
 					}
272 272
 				}
273 273
 
274
-				if(isset($_REQUEST['attribute_group_order']) && ($attribute_group_order = (array) $_REQUEST['attribute_group_order']) && ($attribute_group_order != '')){
275
-					foreach($attribute_group_order as $groupIdentifier => $newOrder){
274
+				if (isset($_REQUEST['attribute_group_order']) && ($attribute_group_order = (array)$_REQUEST['attribute_group_order']) && ($attribute_group_order != '')) {
275
+					foreach ($attribute_group_order as $groupIdentifier => $newOrder) {
276 276
 						$newOrder = str_replace('attribute_', '', $newOrder);
277 277
 						$order = explode(',', $newOrder);
278 278
 						$groupId = str_replace('newOrder', '', $groupIdentifier);
279 279
 						$i = 1;
280
-						foreach($order as $element){
281
-							if($element != ''){
282
-								if((int)$groupId > 0){
280
+						foreach ($order as $element) {
281
+							if ($element != '') {
282
+								if ((int)$groupId > 0) {
283 283
 									$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $element, 'valid', $id);
284 284
 									$validElement = $wpdb->get_var($query);
285
-									if(!empty($validElement)){
285
+									if (!empty($validElement)) {
286 286
 										$query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id);
287 287
 									}
288
-									else{
288
+									else {
289 289
 										$query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i);
290 290
 									}
291 291
 									$wpdb->query($query);
292 292
 								}
293
-								else{
293
+								else {
294 294
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id));
295 295
 								}
296 296
 								$i++;
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 						}
299 299
 					}
300 300
 				}
301
-				if(!empty($_REQUEST['wpshop_attribute_set_section']) && $wpshop_attribute_set_section = (array) $_REQUEST['wpshop_attribute_set_section']){
302
-					foreach($wpshop_attribute_set_section as $set_section_id => $set_section_options){
303
-						if(!empty($set_section_options) && is_array($set_section_options)){
301
+				if (!empty($_REQUEST['wpshop_attribute_set_section']) && $wpshop_attribute_set_section = (array)$_REQUEST['wpshop_attribute_set_section']) {
302
+					foreach ($wpshop_attribute_set_section as $set_section_id => $set_section_options) {
303
+						if (!empty($set_section_options) && is_array($set_section_options)) {
304 304
 							$set_section_options['default_group'] = (!empty($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) && (sanitize_key($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) == $set_section_id)) ? 'yes' : 'no';
305 305
 							$set_section_options['last_update_date'] = current_time('mysql', 0);
306 306
 							$set_section_options['display_on_frontend'] = (!empty($set_section_options['display_on_frontend']) && ($set_section_options['display_on_frontend'] == 'yes')) ? 'yes' : 'no';
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 					}
310 310
 				}
311 311
 
312
-				if ( !empty( $set_section ) ) {
312
+				if (!empty($set_section)) {
313 313
 					$parent_attribute_set_detail = self::getAttributeSetDetails($set_section, "'valid'");
314
-					if ( !empty($parent_attribute_set_detail) ) {
314
+					if (!empty($parent_attribute_set_detail)) {
315 315
 
316 316
 						foreach ($parent_attribute_set_detail as $section => $section_detail) {
317 317
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status'=>'valid', 'attribute_set_id' => $id, 'creation_date'=>current_time('mysql', 0), 'code'=>$section_detail['code'], 'name'=>$section_detail['name'], 'default_group'=>$section_detail['is_default_group'], 'backend_display_type'=>$section_detail['backend_display_type'], 'used_in_shop_type'=>$section_detail['used_in_shop_type'], 'display_on_frontend'=>$section_detail['display_on_frontend']));
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 				}
326 326
 
327 327
 				/*	If the current group is selected as default group set all others for current entity at no	*/
328
-				if($attribute_set_parameter['default_set'] == 'yes'){
328
+				if ($attribute_set_parameter['default_set'] == 'yes') {
329 329
 					$entity_to_take = 0;
330
-					if(isset($_REQUEST['attribute_set_group_id']) && ($_REQUEST['attribute_set_group_id'] != '')){
330
+					if (isset($_REQUEST['attribute_set_group_id']) && ($_REQUEST['attribute_set_group_id'] != '')) {
331 331
 						$entity_to_take = sanitize_key($_REQUEST['attribute_set_group_id']);
332 332
 					}
333
-					if(isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')){
333
+					if (isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')) {
334 334
 						$entity_to_take = $attribute_set_parameter['entity_id'];
335 335
 					}
336
-					if($entity_to_take > 0){
336
+					if ($entity_to_take > 0) {
337 337
 						$query = $wpdb->prepare("UPDATE " . self::getDbTable() . " SET default_set = 'no' WHERE id != %d AND entity_id = %d", $id, $entity_to_take);
338 338
 						$wpdb->query($query);
339 339
 					}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 				$pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage);
345 345
 				/* if(($pageAction == 'edit') || ($pageAction == 'save'))
346 346
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
347
-				else */if($pageAction == 'add')
348
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id));
349
-				elseif($pageAction == 'delete')
350
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id));
347
+				else */if ($pageAction == 'add')
348
+					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
349
+				elseif ($pageAction == 'delete')
350
+					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
351 351
 			}
352
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
352
+			elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
353 353
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
354 354
 		}
355 355
 
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 	    //Create an instance of our package class...
365 365
 	    $wpshop_list_table = new wpshop_attributes_set_custom_List_table();
366 366
 	    //Fetch, prepare, sort, and filter our data...
367
-		$status="'valid', 'moderated'";
367
+		$status = "'valid', 'moderated'";
368 368
 		$attribute_set_list = array();
369
-		if(!empty($_REQUEST['attribute_groups_status'])){
370
-			$status="'".sanitize_text_field($_REQUEST['attribute_groups_status'])."'";
369
+		if (!empty($_REQUEST['attribute_groups_status'])) {
370
+			$status = "'" . sanitize_text_field($_REQUEST['attribute_groups_status']) . "'";
371 371
 		}
372 372
 		$attr_set_list = wpshop_attributes_set::getElement('', $status);
373
-		$i=0;
374
-		foreach($attr_set_list as $attr_set){
375
-			if(!empty($attr_set->id)){
373
+		$i = 0;
374
+		foreach ($attr_set_list as $attr_set) {
375
+			if (!empty($attr_set->id)) {
376 376
 				$attribute_set_list[$i]['id'] = $attr_set->id;
377 377
 				$attribute_set_list[$i]['name'] = $attr_set->name;
378 378
 				$attribute_set_list[$i]['status'] = $attr_set->status;
@@ -380,18 +380,18 @@  discard block
 block discarded – undo
380 380
 				$attribute_set_details = self::getAttributeSetDetails($attr_set->id, "'valid'");
381 381
 
382 382
 				$attribute_set_list[$i]['content'] = '';
383
-				if(!empty($attribute_set_details)){
384
-					foreach($attribute_set_details as $set_details){
385
-						$attribute_set_list[$i]['content'] .= '<div><a href="'.admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$attr_set->id.'#attribute_group_'.$set_details['id']).'" >'.__($set_details['name'],'wpshop').'</a>  ';
386
-						$has_att=false;
387
-						foreach($set_details['attribut'] as $set_detail){
388
-							if(!empty($set_detail->frontend_label) && ( $set_detail->code != 'product_attribute_set_id' ) ){
389
-								$attribute_set_list[$i]['content'] .= __($set_detail->frontend_label,'wpshop').', ';
390
-								$has_att=true;
383
+				if (!empty($attribute_set_details)) {
384
+					foreach ($attribute_set_details as $set_details) {
385
+						$attribute_set_list[$i]['content'] .= '<div><a href="' . admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $attr_set->id . '#attribute_group_' . $set_details['id']) . '" >' . __($set_details['name'], 'wpshop') . '</a>  ';
386
+						$has_att = false;
387
+						foreach ($set_details['attribut'] as $set_detail) {
388
+							if (!empty($set_detail->frontend_label) && ($set_detail->code != 'product_attribute_set_id')) {
389
+								$attribute_set_list[$i]['content'] .= __($set_detail->frontend_label, 'wpshop') . ', ';
390
+								$has_att = true;
391 391
 							}
392 392
 						}
393
-						if(!empty($attribute_set_list[$i]['content'])){
394
-							if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2);
393
+						if (!empty($attribute_set_list[$i]['content'])) {
394
+							if ($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'], 0, -2);
395 395
 							$attribute_set_list[$i]['content'] .= '</div>';
396 396
 						}
397 397
 					}
@@ -430,45 +430,45 @@  discard block
 block discarded – undo
430 430
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
431 431
 		$form_more_content = $the_form_content_hidden = $the_form_general_content = '';
432 432
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add';
433
-		$bloc_list=array();
433
+		$bloc_list = array();
434 434
 
435 435
 		$editedItem = '';
436
-		if($itemToEdit != '')
436
+		if ($itemToEdit != '')
437 437
 			$editedItem = self::getElement($itemToEdit);
438 438
 
439
-		foreach($dbFieldList as $input_key => $input_def){
439
+		foreach ($dbFieldList as $input_key => $input_def) {
440 440
 			$input_name = $input_def['name'];
441 441
 			$input_value = $input_def['value'];
442
-			$input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_name;
442
+			$input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_name;
443 443
 
444 444
 			$attributeAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : '';
445 445
 			$attributeFormValue = isset($_REQUEST[self::getDbTable()][$input_name]) ? sanitize_text_field($_REQUEST[self::getDbTable()][$input_name]) : '';
446 446
 
447 447
 			/*	Get value by checking current object type	*/
448 448
 			$currentFieldValue = $input_value;
449
-			if(is_object($editedItem))
449
+			if (is_object($editedItem))
450 450
 				$currentFieldValue = $editedItem->$input_name;
451
-			elseif(($attributeAction != '') && ($attributeFormValue != ''))
451
+			elseif (($attributeAction != '') && ($attributeFormValue != ''))
452 452
 				$currentFieldValue = $attributeFormValue;
453 453
 
454 454
 			/*	Check if the field must be hidden	*/
455
-			if(in_array($input_name, $attribute_hidden_field))
455
+			if (in_array($input_name, $attribute_hidden_field))
456 456
 				$input_def['type'] = 'hidden';
457 457
 			if ($input_name == 'entity_id') {
458 458
 				$input_def['type'] = 'select';
459 459
 				$input_def['possible_value'] = wpshop_entities::get_entities_list();
460 460
 
461 461
 				$input_def['valueToPut'] = 'index';
462
-				if ( is_object($editedItem) || (count($input_def['possible_value'])==1) ) {
462
+				if (is_object($editedItem) || (count($input_def['possible_value']) == 1)) {
463 463
 					$input_def['type'] = 'hidden';
464
-					$currentFieldValue=(count($input_def['possible_value'])==1)?$input_def['possible_value'][0]->id:$currentFieldValue;
464
+					$currentFieldValue = (count($input_def['possible_value']) == 1) ? $input_def['possible_value'][0]->id : $currentFieldValue;
465 465
 				}
466 466
 				$input_def['name'] = $input_name;
467 467
 				$input_def['value'] = $currentFieldValue;
468 468
 
469
-				$i=0;
470
-				foreach($input_def['possible_value'] as $entity_id => $entity_name) {
471
-					if($i <= 0){
469
+				$i = 0;
470
+				foreach ($input_def['possible_value'] as $entity_id => $entity_name) {
471
+					if ($i <= 0) {
472 472
 						$current_entity_id = $entity_id;
473 473
 					}
474 474
 					$i++;
@@ -477,19 +477,19 @@  discard block
 block discarded – undo
477 477
 				$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
478 478
 			}
479 479
 			else {
480
-				if(in_array($input_name, array('status', 'default_set'))){
480
+				if (in_array($input_name, array('status', 'default_set'))) {
481 481
 					$input_def['type'] = 'checkbox';
482
-					switch($input_name){
482
+					switch ($input_name) {
483 483
 						case 'status':
484 484
 							$input_name = __('Use this attribute group', 'wpshop');
485 485
 							$input_def['possible_value'] = array('valid');
486
-							$input_def_id.='_valid';
487
-							$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
486
+							$input_def_id .= '_valid';
487
+							$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
488 488
 						break;
489 489
 						case 'default_set':
490 490
 							$input_def['possible_value'] = array('yes');
491
-							$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group as default group in selected element', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
492
-							$input_def_id.='_yes';
491
+							$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group as default group in selected element', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
492
+							$input_def_id .= '_yes';
493 493
 						break;
494 494
 					}
495 495
 				}
@@ -497,61 +497,61 @@  discard block
 block discarded – undo
497 497
 				$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
498 498
 			}
499 499
 
500
-			if($input_def['type'] != 'hidden'){
500
+			if ($input_def['type'] != 'hidden') {
501 501
 				$the_form_general_content .= '
502
-		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_name.'" >
503
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td>
504
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td>
502
+		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_name . '" >
503
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_name . '" ><label for="' . $input_def_id . '" >' . __($input_name, 'wpshop') . '</label></td>
504
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_name . '" >' . $the_input . '</td>
505 505
 		</tr>';
506 506
 			}
507
-			else{
507
+			else {
508 508
 				$the_form_content_hidden .= '
509 509
 		' . $the_input;
510 510
 			}
511 511
 		}
512 512
 
513
-		if( empty($itemToEdit) ) {
514
-			$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  self::getDbTable(), self::currentPageCode, false);
513
+		if (empty($itemToEdit)) {
514
+			$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false);
515 515
 			$the_form_general_content .= '
516 516
 			<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_existing_attribute_set_copy_from" >
517
-				<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="'.$input_def_id.'" >' . __('Create the new group from an existing', 'wpshop') . '</label></td>
517
+				<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="' . $input_def_id . '" >' . __('Create the new group from an existing', 'wpshop') . '</label></td>
518 518
 				<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_existing_attribute_set_copy_from" >' . $the_input . '</td>
519 519
 			</tr>';
520 520
 		}
521 521
 		$the_form_general_content = '
522 522
 <table class="wpshop_' . self::currentPageCode . '_edition_table wpshop_' . self::currentPageCode . '_edition_table_main_info" >
523
-'.$the_form_general_content.'
523
+'.$the_form_general_content . '
524 524
 </table>';
525 525
 
526 526
 		/*	Default content for the current page	*/
527
-		$bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop');
528
-		$bloc_list[self::currentPageCode]['main_info']['content']=$the_form_general_content;
527
+		$bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop');
528
+		$bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content;
529 529
 
530
-		if(is_object($editedItem)){
531
-			$bloc_list[self::currentPageCode]['detail']['title']=__('Attribute group section details', 'wpshop');
532
-			$bloc_list[self::currentPageCode]['detail']['content']=self::attributeSetDetailsManagement($itemToEdit);
530
+		if (is_object($editedItem)) {
531
+			$bloc_list[self::currentPageCode]['detail']['title'] = __('Attribute group section details', 'wpshop');
532
+			$bloc_list[self::currentPageCode]['detail']['content'] = self::attributeSetDetailsManagement($itemToEdit);
533 533
 		}
534 534
 
535 535
 		$the_form = '
536 536
 <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" >
537
-' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action'])?sanitize_text_field($_REQUEST['action']):'save'), 'hidden') . '
538
-' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . '
539
-	<div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >';
537
+' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'save'), 'hidden') . '
538
+' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . '
539
+	<div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode . '" >';
540 540
 
541
-		if(($action == 'add') && (current_user_can('wpshop_add_attribute_set')))
541
+		if (($action == 'add') && (current_user_can('wpshop_add_attribute_set')))
542 542
 			$the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
543
-		elseif(current_user_can('wpshop_edit_attribute_set'))
543
+		elseif (current_user_can('wpshop_edit_attribute_set'))
544 544
 			$the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
545 545
 
546
-		if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add'))
547
-			$the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
546
+		if (current_user_can('wpshop_delete_attribute_set') && ($action != 'add'))
547
+			$the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
548 548
 
549 549
 		$the_form .= '
550 550
 	</div>
551 551
 </form>
552 552
 <script type="text/javascript" >
553 553
 	wpshop(document).ready(function(){
554
-		wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
554
+		wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
555 555
 
556 556
 		jQuery("#wpshop_attribute_set_edition_table_field_id_entity_id").change(function(){
557 557
 			jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html(jQuery("#wpshopLoadingPicture").html());
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	*
576 576
 	*	@return string $currentPageButton The html output code with the different button to add to the interface
577 577
 	*/
578
-	function getPageFormButton($element_id = 0){
578
+	function getPageFormButton($element_id = 0) {
579 579
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add';
580 580
 		$currentPageButton = '';
581 581
 
@@ -590,15 +590,15 @@  discard block
 block discarded – undo
590 590
 	*
591 591
 	*	@return object $elements A wordpress database object containing the element list
592 592
 	*/
593
-	public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){
593
+	public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = '') {
594 594
 		global $wpdb;
595 595
 		$elements = array();
596 596
 		$moreQuery = "";
597 597
 		$moreQueryArgs = array();
598 598
 
599
-		if($elementId != '')
599
+		if ($elementId != '')
600 600
 		{
601
-			switch($whatToSearch)
601
+			switch ($whatToSearch)
602 602
 			{
603 603
 				case 'entity_code':
604 604
 					$moreQuery = "
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 			$moreQueryArgs[] = $elementId;
629 629
 		}
630 630
 
631
-		if ( !empty($entity_id) ) {
631
+		if (!empty($entity_id)) {
632 632
 			$moreQuery .= "
633 633
 			AND ATTRIBUTE_SET.entity_id = %d ";
634 634
 			$moreQueryArgs[] = $entity_id;
635 635
 		}
636 636
 
637
-		if( empty($entity_id) ) {
637
+		if (empty($entity_id)) {
638 638
 			$moreQuery .= "AND 1=%d";
639 639
 			$moreQueryArgs[] = 1;
640 640
 		}
@@ -643,11 +643,11 @@  discard block
 block discarded – undo
643 643
 			"SELECT ATTRIBUTE_SET.*, ENTITIES.post_name as entity
644 644
 			FROM " . self::getDbTable() . " AS ATTRIBUTE_SET
645 645
 				INNER JOIN " . $wpdb->posts . " AS ENTITIES ON (ENTITIES.ID = ATTRIBUTE_SET.entity_id)
646
-			WHERE ATTRIBUTE_SET.status IN (".$elementStatus.") " . $moreQuery, $moreQueryArgs
646
+			WHERE ATTRIBUTE_SET.status IN (".$elementStatus . ") " . $moreQuery, $moreQueryArgs
647 647
 		);
648 648
 
649 649
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
650
-		if(($elementId == '') || ($resultList == 'all'))
650
+		if (($elementId == '') || ($resultList == 'all'))
651 651
 		{
652 652
 			$elements = $wpdb->get_results($query);
653 653
 		}
@@ -666,21 +666,21 @@  discard block
 block discarded – undo
666 666
 	*
667 667
 	*	@return string $attributeSetDetailsManagement The html output of management interface
668 668
 	*/
669
-	public static function attributeSetDetailsManagement($attributeSetId = ''){
669
+	public static function attributeSetDetailsManagement($attributeSetId = '') {
670 670
 		global $validAttributeList; global $wpdb;
671 671
 		$user_more_script = $add_button = '';
672 672
 		$end_line_display = array();
673 673
 		/** Check if it's billing or Shipping **/
674
-		if ( !empty($attributeSetId) ) {
675
-			$shipping_option = get_option( 'wpshop_shipping_address_choice' );
676
-			$billing_option = get_option( 'wpshop_billing_address' );
674
+		if (!empty($attributeSetId)) {
675
+			$shipping_option = get_option('wpshop_shipping_address_choice');
676
+			$billing_option = get_option('wpshop_billing_address');
677 677
 
678
-			if ( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId ) {
679
-				$end_line_display = ( !empty( $shipping_option['display_model'] ) ) ? $shipping_option['display_model'] : array();
678
+			if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId) {
679
+				$end_line_display = (!empty($shipping_option['display_model'])) ? $shipping_option['display_model'] : array();
680 680
 			}
681 681
 
682
-			if ( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId ) {
683
-				$end_line_display = ( !empty( $billing_option['display_model'] ) ) ? $billing_option['display_model'] : array();
682
+			if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId) {
683
+				$end_line_display = (!empty($billing_option['display_model'])) ? $billing_option['display_model'] : array();
684 684
 			}
685 685
 		}
686 686
 
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
 
689 689
 		$attributeSetDetailsManagement = '
690 690
 <div id="managementContainer" >';
691
-	if(current_user_can('wpshop_add_attribute_group')){
691
+	if (current_user_can('wpshop_add_attribute_group')) {
692 692
 		$dialog_title = __('New attribute set section name', 'wpshop');
693 693
 		$dialog_identifier = 'wpshop_new_set_section_add';
694 694
 		$dialog_input_identifier = 'wpshop_new_attribute_set_section_name';
695 695
 		ob_start();
696
-		include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
696
+		include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
697 697
 		$attributeSetDetailsManagement .= ob_get_contents();
698 698
 		ob_end_clean();
699 699
 
@@ -701,39 +701,39 @@  discard block
 block discarded – undo
701 701
 		$add_button_parent_class = 'attribute_set_section_add_new_button';
702 702
 		$add_button_name = 'wpshop_create_new_set_section_top';
703 703
 		ob_start();
704
-		include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php');
704
+		include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php');
705 705
 		$add_button = ob_get_contents();
706 706
 		ob_end_clean();
707 707
 
708 708
 		$user_more_script .= '
709
-			jQuery("#'.$dialog_identifier.'").dialog({
709
+			jQuery("#'.$dialog_identifier . '").dialog({
710 710
 				modal: true,
711 711
 				dialogClass: "wpshop_uidialog_box",
712 712
 				autoOpen:false,
713 713
 				show: "blind",
714 714
 				resizable: false,
715 715
 				buttons:{
716
-					"'.__('Add', 'wpshop').'": function(){
716
+					"'.__('Add', 'wpshop') . '": function(){
717 717
 						jQuery("#managementContainer").load(WPSHOP_AJAX_FILE_URL,{
718 718
 							"post": "true",
719 719
 							"elementCode": "' . self::currentPageCode . '",
720 720
 							"action": "saveNewAttributeSetSection",
721 721
 							"elementType": "attributeSetSection",
722 722
 							"elementIdentifier": "' . $attributeSetId . '",
723
-							"attributeSetSectionName": jQuery("#'.$dialog_input_identifier.'").val()
723
+							"attributeSetSectionName": jQuery("#'.$dialog_input_identifier . '").val()
724 724
 						});
725 725
 						jQuery(this).children("img").show();
726 726
 					},
727
-					"'.__('Cancel', 'wpshop').'": function(){
727
+					"'.__('Cancel', 'wpshop') . '": function(){
728 728
 						jQuery(this).dialog("close");
729 729
 					}
730 730
 				},
731 731
 				close:function(){
732
-					jQuery("#'.$dialog_input_identifier.'").val("");
732
+					jQuery("#'.$dialog_input_identifier . '").val("");
733 733
 				}
734 734
 			});
735
-			jQuery(".'.$add_button_parent_class.' input").click(function(){
736
-				jQuery("#'.$dialog_identifier.'").dialog("open");
735
+			jQuery(".'.$add_button_parent_class . ' input").click(function(){
736
+				jQuery("#'.$dialog_identifier . '").dialog("open");
737 737
 			});';
738 738
 	}
739 739
 	$attributeSetDetailsManagement .= '
@@ -742,62 +742,62 @@  discard block
 block discarded – undo
742 742
 
743 743
 		/*	Get information about the current attribute set we are editing	*/
744 744
 		$attributeSetDetails = self::getAttributeSetDetails($attributeSetId);
745
-		if(is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)){
745
+		if (is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)) {
746 746
 			/*	Build output with the current attribute set details	*/
747
-			foreach($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup){
747
+			foreach ($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup) {
748 748
 				/*	Check possible action for general code	*/
749 749
 				$elementActionClass = 'wpshop_attr_set_section_name';
750 750
 				$edition_area = $edit_button = '';
751
-				if ( current_user_can('wpshop_edit_attribute_group') ) {
751
+				if (current_user_can('wpshop_edit_attribute_group')) {
752 752
 					$elementActionClass = 'wpshop_attr_set_section_name_editable';
753 753
 					$edit_button = '
754
-			<a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'].'" title="'.__('Edit this section', 'wpshop').'"></a>';
754
+			<a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Edit this section', 'wpshop') . '"></a>';
755 755
 
756 756
 					$tpl_component = array();
757 757
 					$tpl_component['ADMIN_GROUP_IDENTIFIER'] = str_replace('-', '_', sanitize_title($attributeSetDetailsGroup['id']));
758 758
 					$tpl_component['ADMIN_GROUP_ID'] = $attributeSetDetailsGroup['id'];
759 759
 					$tpl_component['ADMIN_GROUP_NAME'] = __($attributeSetDetailsGroup['name'], 'wpshop');
760
-					$tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='fixed-tab')?' selected="selected"':'');
761
-					$tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='movable-tab')?' selected="selected"':'');
762
-					$tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend']=='yes')?' checked="checked"':'');
760
+					$tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'fixed-tab') ? ' selected="selected"' : '');
761
+					$tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'movable-tab') ? ' selected="selected"' : '');
762
+					$tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend'] == 'yes') ? ' checked="checked"' : '');
763 763
 					$edition_area = wpshop_display::display_template_element('wpshop_admin_attr_set_section_params', $tpl_component, array(), 'admin');
764 764
 					unset($tpl_component);
765 765
 				}
766 766
 //<td rowspan="2" class="wpshop_attribute_set_section_detail_table_default_td" ><input title="'.__('Default section', 'wpshop').'" type="radio" name="wpshop_attribute_set_section_is_default_of_set" '.($is_default?'checked="checked" ':'').'id="wpshop_attribute_set_section_is_default_of_set_'.$attributeSetDetailsGroup['id'].'" value="'.$attributeSetDetailsGroup['id'].'" /></td>
767
-				$is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group']=='yes')?true:false);
767
+				$is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group'] == 'yes') ? true : false);
768 768
 				$attributeSetDetailsManagement .= '
769
-	<li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_'.($is_default?'is_default':'normal').'" >
769
+	<li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_' . ($is_default ? 'is_default' : 'normal') . '" >
770 770
 		<table class="wpshpop_attribute_set_section_detail_table" >
771 771
 			<tr>
772 772
 				<td id="wpshop_attr_set_section_name_' . $attributeSetDetailsGroup['id'] . '" class="' . $elementActionClass . '" >' . __($attributeSetDetailsGroup['name'], 'wpshop') . '</td>
773 773
 			</tr>
774 774
 			<tr>
775 775
 				<td>
776
-					<input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' .( ( !empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) ) ? implode( ',', $end_line_display[$attributeSetIDGroup] ) : '' ). '" />';
776
+					<input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' . ((!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup])) ? implode(',', $end_line_display[$attributeSetIDGroup]) : '') . '" />';
777 777
 
778 778
 				/*	Add the set section details	*/
779 779
 				$price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES);
780 780
 				unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]);
781 781
 				$no_delete_button = false;
782
-				if ( is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1) ) {
782
+				if (is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1)) {
783 783
 					$attributeSetDetailsManagement .= '
784 784
 					<ul id="attribute_group_' . $attributeSetIDGroup . '_details" class="wpshop_attr_set_section_details" >';
785 785
 					ksort($attributeSetDetailsGroup['attribut']);
786 786
 					$end_line_id = 0;
787
-					foreach ( $attributeSetDetailsGroup['attribut'] as $attributInGroup ) {
788
-						if ( in_array($attributInGroup->code, $price_tab) ){
787
+					foreach ($attributeSetDetailsGroup['attribut'] as $attributInGroup) {
788
+						if (in_array($attributInGroup->code, $price_tab)) {
789 789
 							$no_delete_button = true;
790 790
 						}
791
-						if ( !empty($attributInGroup->id) && ( $attributInGroup->code != 'product_attribute_set_id' ) ) {
791
+						if (!empty($attributInGroup->id) && ($attributInGroup->code != 'product_attribute_set_id')) {
792 792
 
793 793
 						$attributeSetDetailsManagement .= '
794
-						<li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop')  . '</li>';
794
+						<li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop') . '</li>';
795 795
 
796 796
 
797
-						if ( !empty($end_line_display) && !empty($end_line_display[ $attributeSetIDGroup ]) && in_array('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ]) ) {
798
-							$key = array_search('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ] );
799
-							if ( !empty($end_line_display[ $attributeSetIDGroup ][$key + 1]) && $end_line_display[ $attributeSetIDGroup ][$key + 1] == 'wps-attribute-end-line-'.$end_line_id ) {
800
-								$attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li>';
797
+						if (!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) && in_array('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup])) {
798
+							$key = array_search('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup]);
799
+							if (!empty($end_line_display[$attributeSetIDGroup][$key + 1]) && $end_line_display[$attributeSetIDGroup][$key + 1] == 'wps-attribute-end-line-' . $end_line_id) {
800
+								$attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li>';
801 801
 								$end_line_id++;
802 802
 							}
803 803
 						}
@@ -809,15 +809,15 @@  discard block
 block discarded – undo
809 809
 					</ul>';
810 810
 				}
811 811
 
812
-					$attributeSetDetailsManagement .= $edition_area.'
812
+					$attributeSetDetailsManagement .= $edition_area . '
813 813
 				</td>
814 814
 			</tr>
815 815
 		</table>
816 816
 
817 817
 		<div class="wpshop_admin_toolbox wpshop_attr_set_section_tool_box" >' . $edit_button;
818
-			if ( current_user_can('wpshop_delete_attribute_group') && !$no_delete_button ) {
818
+			if (current_user_can('wpshop_delete_attribute_group') && !$no_delete_button) {
819 819
 				$attributeSetDetailsManagement .= '
820
-			<a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'].'" title="'.__('Delete this section', 'wpshop').'"></a>';
820
+			<a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Delete this section', 'wpshop') . '"></a>';
821 821
 			}
822 822
 			$attributeSetDetailsManagement .= '
823 823
 		</div>
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 
838 838
 		/*	Get the not affected attribute list	*/
839 839
 		$notAffectedAttributeList = self::get_not_affected_attribute($attributeSetId, $attributeSetDetailsGroup['entity_id']);
840
-		if(count($notAffectedAttributeList) > 0){
841
-			foreach($notAffectedAttributeList as $notAffectedAttribute){
842
-				if( (is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ( $notAffectedAttribute->code != 'product_attribute_set_id' ) && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id) ){
840
+		if (count($notAffectedAttributeList) > 0) {
841
+			foreach ($notAffectedAttributeList as $notAffectedAttribute) {
842
+				if ((is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ($notAffectedAttribute->code != 'product_attribute_set_id') && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id)) {
843 843
 
844 844
 				$attributeSetDetailsManagement .= '
845 845
 			<li class="ui-state-default attribute" id="attribute_' . $notAffectedAttribute->id . '" >' . __($notAffectedAttribute->frontend_label, 'wpshop') . '</li>';
@@ -853,20 +853,20 @@  discard block
 block discarded – undo
853 853
 		</fieldset>
854 854
 	</div>';
855 855
 
856
-		if ( !empty($attributeSetId) ) {
857
-			$query  = $wpdb->prepare( 'SELECT entity_id FROM '.WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE id = %d', $attributeSetId );
858
-			$entity_id = $wpdb->get_var( $query );
859
-			if ( !empty($entity_id) ) {
860
-				$entity_post = get_post( $entity_id );
861
-				if( !empty( $entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) {
862
-					$attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li></ul>';
856
+		if (!empty($attributeSetId)) {
857
+			$query = $wpdb->prepare('SELECT entity_id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE id = %d', $attributeSetId);
858
+			$entity_id = $wpdb->get_var($query);
859
+			if (!empty($entity_id)) {
860
+				$entity_post = get_post($entity_id);
861
+				if (!empty($entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) {
862
+					$attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li></ul>';
863 863
 				}
864 864
 			}
865 865
 		}
866
-		if(current_user_can('wpshop_delete_attribute_group')){
866
+		if (current_user_can('wpshop_delete_attribute_group')) {
867 867
 			$user_more_script .= '
868 868
 			jQuery(".wpshop_attr_tool_box_delete").click(function(){
869
-				if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop').'"))){
869
+				if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop') . '"))){
870 870
 					jQuery("#ajax-response").load(WPSHOP_AJAX_FILE_URL,{
871 871
 						"post": "true",
872 872
 						"elementCode": "' . self::currentPageCode . '",
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 		$attributeSetDetailsManagement .= '
882 882
 	<script type="text/javascript" >
883 883
 		wpshop(document).ready(function(){
884
-			make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");'.$user_more_script.'
884
+			make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");' . $user_more_script . '
885 885
 		});
886 886
 	</script>
887 887
 	<div class="wpshop_cls"></div>
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 	*
949 949
 	*	@return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set
950 950
 	*/
951
-	public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){
951
+	public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'") {
952 952
 		global $wpdb, $validAttributeList;
953 953
 		$attributeSetDetailsGroups = '';
954 954
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			$attributeSetId);
969 969
 		$attributeSetDetails = $wpdb->get_results($query);
970 970
 
971
-		foreach ( $attributeSetDetails as $attributeGroup ) {
971
+		foreach ($attributeSetDetails as $attributeGroup) {
972 972
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribute_set_id'] = $attributeGroup->attribute_set_id;
973 973
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['id'] = $attributeGroup->attribute_detail_id;
974 974
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['code'] = $attributeGroup->attr_group_code;
@@ -979,17 +979,17 @@  discard block
 block discarded – undo
979 979
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['display_on_frontend'] = $attributeGroup->display_on_frontend;
980 980
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['entity_id'] = $attributeGroup->entity_id;
981 981
 
982
-			if ( empty($done_position) || empty($done_position[$attributeGroup->attr_group_id]) ) {
982
+			if (empty($done_position) || empty($done_position[$attributeGroup->attr_group_id])) {
983 983
 				$done_position[$attributeGroup->attr_group_id] = array();
984 984
 			}
985 985
 			$position_to_take = $attributeGroup->attr_position_in_group;
986
-			if ( in_array($position_to_take, $done_position[$attributeGroup->attr_group_id]) ) {
986
+			if (in_array($position_to_take, $done_position[$attributeGroup->attr_group_id])) {
987 987
 				$position_to_take = max($done_position[$attributeGroup->attr_group_id]) + 1;
988 988
 			}
989 989
 			$done_position[$attributeGroup->attr_group_id][] = $position_to_take;
990 990
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribut'][$position_to_take] = $attributeGroup;
991 991
 			$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['is_used_in_quick_add_form'] = $attributeGroup->is_used_in_quick_add_form;
992
-			if ( in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
992
+			if (in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) {
993 993
 				$attributeSetDetailsGroups[$attributeGroup->attr_group_id]['prices'][$attributeGroup->code] = $attributeGroup;
994 994
 			}
995 995
 			$validAttributeList[] = $attributeGroup->id;
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 	*
1006 1006
 	*	@return array $attributeSetDetails The List of attribute not affected
1007 1007
 	*/
1008
-	public static function get_not_affected_attribute($attributeSetId, $entity_set_id){
1008
+	public static function get_not_affected_attribute($attributeSetId, $entity_set_id) {
1009 1009
 		global $wpdb;
1010 1010
 
1011 1011
 		$query = $wpdb->prepare(
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	*
1046 1046
 	*	@return object $entitySets The entity sets list for the given entity
1047 1047
 	*/
1048
-	public static function get_attribute_set_list_for_entity($entityId){
1048
+	public static function get_attribute_set_list_for_entity($entityId) {
1049 1049
 		global $wpdb;
1050 1050
 		$entitySetList = '';
1051 1051
 
@@ -1069,39 +1069,39 @@  discard block
 block discarded – undo
1069 1069
 		global $wpdb;
1070 1070
 
1071 1071
 		$query = '
1072
-		SELECT '.WPSHOP_DBT_ATTRIBUTE.'.frontend_label, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.value AS value_decimal, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.value AS value_datetime, '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.value AS value_integer,
1073
-				'.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.value AS value_text, '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.value AS value_varchar, '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.unit AS unit, '.WPSHOP_DBT_ATTRIBUTE.'.frontend_verification
1074
-		FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'
1075
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE.' ON '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1076
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1077
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1078
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1079
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1080
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id
1081
-			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT.' ON (
1082
-				'.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.unit_id
1083
-				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.unit_id
1084
-				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.unit_id
1085
-				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.unit_id
1086
-				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.unit_id
1072
+		SELECT '.WPSHOP_DBT_ATTRIBUTE . '.frontend_label, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.value AS value_decimal, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.value AS value_datetime, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.value AS value_integer,
1073
+				'.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.value AS value_text, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.value AS value_varchar, ' . WPSHOP_DBT_ATTRIBUTE_UNIT . '.unit AS unit, ' . WPSHOP_DBT_ATTRIBUTE . '.frontend_verification
1074
+		FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '
1075
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE . ' ON ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1076
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1077
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1078
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1079
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1080
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id
1081
+			LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT . ' ON (
1082
+				'.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.unit_id
1083
+				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.unit_id
1084
+				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.unit_id
1085
+				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.unit_id
1086
+				OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.unit_id
1087 1087
 			)
1088 1088
 		WHERE
1089
-			'.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.status="valid"
1090
-			AND '.WPSHOP_DBT_ATTRIBUTE.'.status="valid"
1091
-			AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_group_id IN ('.$atts['sid'].')
1089
+			'.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.status="valid"
1090
+			AND '.WPSHOP_DBT_ATTRIBUTE . '.status="valid"
1091
+			AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_group_id IN (' . $atts['sid'] . ')
1092 1092
 			AND (
1093
-				'.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.entity_id='.$atts['pid'].'
1094
-				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.entity_id='.$atts['pid'].'
1095
-				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.entity_id='.$atts['pid'].'
1096
-				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.entity_id='.$atts['pid'].'
1097
-				OR '.WPSHOP_DBT_ATTRIBUTE.'_value_varchar.entity_id='.$atts['pid'].'
1093
+				'.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.entity_id=' . $atts['pid'] . '
1094
+				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.entity_id=' . $atts['pid'] . '
1095
+				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.entity_id=' . $atts['pid'] . '
1096
+				OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.entity_id=' . $atts['pid'] . '
1097
+				OR '.WPSHOP_DBT_ATTRIBUTE . '_value_varchar.entity_id=' . $atts['pid'] . '
1098 1098
 			)
1099 1099
 		';
1100 1100
 		$data = $wpdb->get_results($query);
1101
-		foreach($data as $d) {
1101
+		foreach ($data as $d) {
1102 1102
 			$value_style_start = $value_style_end = '';
1103
-			if ( !empty($d->frontend_verification) ) {
1104
-				switch ( $d->frontend_verification ) {
1103
+			if (!empty($d->frontend_verification)) {
1104
+				switch ($d->frontend_verification) {
1105 1105
 					case 'phone':
1106 1106
 						$value_style_start = '<a href="tel:' . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . '" >';
1107 1107
 						$value_style_end = '</a>';
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 					break;
1113 1113
 				}
1114 1114
 			}
1115
-			echo '<strong>'.__($d->frontend_label, 'wpshop').'</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . ( !empty($d->unit) ? ' ('.$d->unit.')' : '' ) . '<br />';
1115
+			echo '<strong>' . __($d->frontend_label, 'wpshop') . '</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . (!empty($d->unit) ? ' (' . $d->unit . ')' : '') . '<br />';
1116 1116
 		}
1117 1117
 	}
1118 1118
 
@@ -1127,31 +1127,31 @@  discard block
 block discarded – undo
1127 1127
 	 *
1128 1128
 	 * @return string Le code html permettant d'afficher la liste des groupes et/ou sous-groupes d'attributs
1129 1129
 	 */
1130
-	public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true){
1130
+	public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true) {
1131 1131
 		$the_input = __('There is no attribute set for this entity', 'wpshop');
1132 1132
 
1133 1133
 		$attr_set_list = wpshop_attributes_set::getElement($entity_id, "'valid'", 'entity_id', 'all');
1134
-		if ( !empty($attr_set_list) ) {
1134
+		if (!empty($attr_set_list)) {
1135 1135
 			$the_input = '<select name="' . $table . '[set_section]" class="wpshop_' . $page_code . '_set_section" >';
1136 1136
 			if (!$complete_tree) {
1137
-				$the_input .= '<option value="0">'.__('None', 'wpshop').'</option>';
1137
+				$the_input .= '<option value="0">' . __('None', 'wpshop') . '</option>';
1138 1138
 			}
1139 1139
 
1140
-			foreach ( $attr_set_list as $attr_set_index => $attr_set ) {
1141
-				if ( !empty($attr_set->id) ) {
1140
+			foreach ($attr_set_list as $attr_set_index => $attr_set) {
1141
+				if (!empty($attr_set->id)) {
1142 1142
 					$attribute_set_details = wpshop_attributes_set::getAttributeSetDetails($attr_set->id, "'valid'");
1143
-					if ( !empty($attribute_set_details) ) {
1143
+					if (!empty($attribute_set_details)) {
1144 1144
 
1145 1145
 						if ($complete_tree) {
1146
-							$the_input .= '<optgroup label="'.__($attr_set->name, 'wpshop').'" >';
1147
-							foreach ( $attribute_set_details as $set_details ) {
1148
-								$selected = ( ( $attr_set->default_set == 'yes' ) && ( $set_details['is_default_group'] == 'yes' ) ? ' selected="selected"' : '' );
1149
-								$the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>';
1146
+							$the_input .= '<optgroup label="' . __($attr_set->name, 'wpshop') . '" >';
1147
+							foreach ($attribute_set_details as $set_details) {
1148
+								$selected = (($attr_set->default_set == 'yes') && ($set_details['is_default_group'] == 'yes') ? ' selected="selected"' : '');
1149
+								$the_input .= '<option' . $selected . ' value="' . $attr_set->id . '_' . $set_details['id'] . '">' . __($set_details['name'], 'wpshop') . '</option>';
1150 1150
 							}
1151 1151
 							$the_input .= '</optgroup>';
1152 1152
 						}
1153 1153
 						else {
1154
-							$the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>';
1154
+							$the_input .= '<option value="' . $attr_set->id . '">' . __($attr_set->name, 'wpshop') . '</option>';
1155 1155
 						}
1156 1156
 					}
1157 1157
 				}
Please login to merge, or discard this patch.
Braces   +57 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
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' ) ) {
@@ -88,9 +90,9 @@  discard block
 block discarded – undo
88 90
 			if($action == 'edit'){
89 91
 				$editedItem = self::getElement($objectInEdition);
90 92
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop'));
93
+			} elseif($action == 'add') {
94
+							$title = __(self::pageAddingTitle, 'wpshop');
91 95
 			}
92
-			elseif($action == 'add')
93
-				$title = __(self::pageAddingTitle, 'wpshop');
94 96
 		}
95 97
 		return $title;
96 98
 	}
@@ -114,8 +116,7 @@  discard block
 block discarded – undo
114 116
 		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
115 117
 			$editedElement = self::getElement($saveditem);
116 118
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>');
117
-		}
118
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
119
+		} elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
119 120
 			$editedElement = self::getElement($saveditem, "'deleted'");
120 121
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>');
121 122
 		}
@@ -141,14 +142,14 @@  discard block
 block discarded – undo
141 142
 			if(current_user_can('wpshop_edit_attribute_set')){
142 143
 				$attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s');
143 144
 				if($pageAction == 'delete'){
144
-					if(current_user_can('wpshop_delete_attribute_set'))
145
-						$attribute_set_parameter['status'] = 'deleted';
146
-					else
147
-						$actionResult = 'userNotAllowedForActionDelete';
145
+					if(current_user_can('wpshop_delete_attribute_set')) {
146
+											$attribute_set_parameter['status'] = 'deleted';
147
+					} else {
148
+											$actionResult = 'userNotAllowedForActionDelete';
149
+					}
148 150
 				}
149 151
 				$actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable());
150
-			}
151
-			else{
152
+			} else{
152 153
 				$actionResult = 'userNotAllowedForActionEdit';
153 154
 			}
154 155
 
@@ -199,17 +200,15 @@  discard block
 block discarded – undo
199 200
 
200 201
 				}
201 202
 
202
-		}
203
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
203
+		} elseif(($pageAction != '') && (($pageAction == 'delete'))){
204 204
 			if(current_user_can('wpshop_delete_attribute_set')){
205 205
 				$attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s');
206 206
 				$attribute_set_parameter['status'] = 'deleted';
207 207
 				$actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable());
208
+			} else {
209
+							$actionResult = 'userNotAllowedForActionDelete';
208 210
 			}
209
-			else
210
-				$actionResult = 'userNotAllowedForActionDelete';
211
-		}
212
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
211
+		} elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
213 212
 			if(current_user_can('wpshop_add_attribute_set')){
214 213
 				$attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s');
215 214
 				$actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable());
@@ -244,9 +243,9 @@  discard block
 block discarded – undo
244 243
 						}
245 244
 					}
246 245
 				}
246
+			} else {
247
+							$actionResult = 'userNotAllowedForActionAdd';
247 248
 			}
248
-			else
249
-				$actionResult = 'userNotAllowedForActionAdd';
250 249
 		}
251 250
 
252 251
 		/*	When an action is launched and there is a result message	*/
@@ -255,11 +254,12 @@  discard block
 block discarded – undo
255 254
 		/****************************************************************************/
256 255
 		if($actionResult != ''){
257 256
 			$elementIdentifierForMessage = __('the attribute group', 'wpshop');
258
-			if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>';
257
+			if(!empty($attribute_set_parameter['name'])) {
258
+				$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>';
259
+			}
259 260
 			if($actionResult == 'error'){/*	CHANGE HERE FOR SPECIFIC CASE	*/
260 261
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage);
261
-			}
262
-			elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){
262
+			} elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){
263 263
 				/*****************************************************************************************************************/
264 264
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				******************/
265 265
 				/*****************************************************************************************************************/
@@ -284,13 +284,11 @@  discard block
 block discarded – undo
284 284
 									$validElement = $wpdb->get_var($query);
285 285
 									if(!empty($validElement)){
286 286
 										$query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id);
287
-									}
288
-									else{
287
+									} else{
289 288
 										$query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i);
290 289
 									}
291 290
 									$wpdb->query($query);
292
-								}
293
-								else{
291
+								} else{
294 292
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id));
295 293
 								}
296 294
 								$i++;
@@ -344,13 +342,14 @@  discard block
 block discarded – undo
344 342
 				$pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage);
345 343
 				/* if(($pageAction == 'edit') || ($pageAction == 'save'))
346 344
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
347
-				else */if($pageAction == 'add')
348
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id));
349
-				elseif($pageAction == 'delete')
350
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id));
345
+				else */if($pageAction == 'add') {
346
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id));
347
+				} elseif($pageAction == 'delete') {
348
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id));
349
+				}
350
+			} elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) {
351
+							$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
351 352
 			}
352
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
353
-				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
354 353
 		}
355 354
 
356 355
 		self::setMessage($pageMessage);
@@ -391,7 +390,9 @@  discard block
 block discarded – undo
391 390
 							}
392 391
 						}
393 392
 						if(!empty($attribute_set_list[$i]['content'])){
394
-							if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2);
393
+							if($has_att) {
394
+								$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2);
395
+							}
395 396
 							$attribute_set_list[$i]['content'] .= '</div>';
396 397
 						}
397 398
 					}
@@ -433,8 +434,9 @@  discard block
 block discarded – undo
433 434
 		$bloc_list=array();
434 435
 
435 436
 		$editedItem = '';
436
-		if($itemToEdit != '')
437
-			$editedItem = self::getElement($itemToEdit);
437
+		if($itemToEdit != '') {
438
+					$editedItem = self::getElement($itemToEdit);
439
+		}
438 440
 
439 441
 		foreach($dbFieldList as $input_key => $input_def){
440 442
 			$input_name = $input_def['name'];
@@ -446,14 +448,16 @@  discard block
 block discarded – undo
446 448
 
447 449
 			/*	Get value by checking current object type	*/
448 450
 			$currentFieldValue = $input_value;
449
-			if(is_object($editedItem))
450
-				$currentFieldValue = $editedItem->$input_name;
451
-			elseif(($attributeAction != '') && ($attributeFormValue != ''))
452
-				$currentFieldValue = $attributeFormValue;
451
+			if(is_object($editedItem)) {
452
+							$currentFieldValue = $editedItem->$input_name;
453
+			} elseif(($attributeAction != '') && ($attributeFormValue != '')) {
454
+							$currentFieldValue = $attributeFormValue;
455
+			}
453 456
 
454 457
 			/*	Check if the field must be hidden	*/
455
-			if(in_array($input_name, $attribute_hidden_field))
456
-				$input_def['type'] = 'hidden';
458
+			if(in_array($input_name, $attribute_hidden_field)) {
459
+							$input_def['type'] = 'hidden';
460
+			}
457 461
 			if ($input_name == 'entity_id') {
458 462
 				$input_def['type'] = 'select';
459 463
 				$input_def['possible_value'] = wpshop_entities::get_entities_list();
@@ -475,8 +479,7 @@  discard block
 block discarded – undo
475 479
 				}
476 480
 
477 481
 				$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
478
-			}
479
-			else {
482
+			} else {
480 483
 				if(in_array($input_name, array('status', 'default_set'))){
481 484
 					$input_def['type'] = 'checkbox';
482 485
 					switch($input_name){
@@ -503,8 +506,7 @@  discard block
 block discarded – undo
503 506
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td>
504 507
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td>
505 508
 		</tr>';
506
-			}
507
-			else{
509
+			} else{
508 510
 				$the_form_content_hidden .= '
509 511
 		' . $the_input;
510 512
 			}
@@ -538,13 +540,15 @@  discard block
 block discarded – undo
538 540
 ' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . '
539 541
 	<div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >';
540 542
 
541
-		if(($action == 'add') && (current_user_can('wpshop_add_attribute_set')))
542
-			$the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
543
-		elseif(current_user_can('wpshop_edit_attribute_set'))
544
-			$the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
543
+		if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) {
544
+					$the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
545
+		} elseif(current_user_can('wpshop_edit_attribute_set')) {
546
+					$the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
547
+		}
545 548
 
546
-		if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add'))
547
-			$the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
549
+		if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) {
550
+					$the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
551
+		}
548 552
 
549 553
 		$the_form .= '
550 554
 	</div>
@@ -650,8 +654,7 @@  discard block
 block discarded – undo
650 654
 		if(($elementId == '') || ($resultList == 'all'))
651 655
 		{
652 656
 			$elements = $wpdb->get_results($query);
653
-		}
654
-		else
657
+		} else
655 658
 		{
656 659
 			$elements = $wpdb->get_row($query);
657 660
 		}
@@ -1149,8 +1152,7 @@  discard block
 block discarded – undo
1149 1152
 								$the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>';
1150 1153
 							}
1151 1154
 							$the_input .= '</optgroup>';
1152
-						}
1153
-						else {
1155
+						} else {
1154 1156
 							$the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>';
1155 1157
 						}
1156 1158
 					}
Please login to merge, or discard this patch.
includes/librairies/eav/attributes_unit.class.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,6 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	*	Get the url listing slug of the current class
70 70
 	*
71
+	*	@param string $message
71 72
 	*	@return string The table of the class
72 73
 	*/
73 74
 	function setMessage($message)
@@ -519,7 +520,7 @@  discard block
 block discarded – undo
519 520
 	*
520 521
 	*	@param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned
521 522
 	*	@param string $element_status optionnal The status of element to get into database. Default is set to valid element
522
-	*	@param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
523
+	*	@param string $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
523 524
 	*
524 525
 	*	@return object $element_list A wordpress database object containing the attribute list
525 526
 	*/
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -24,89 +24,89 @@  discard block
 block discarded – undo
24 24
 class wpshop_attributes_unit
25 25
 {
26 26
 	/**
27
-	*	Define the database table used in the current class
28
-	*/
27
+	 *	Define the database table used in the current class
28
+	 */
29 29
 	const dbTable = WPSHOP_DBT_ATTRIBUTE_UNIT;
30 30
 	/**
31
-	*	Define the url listing slug used in the current class
32
-	*/
31
+	 *	Define the url listing slug used in the current class
32
+	 */
33 33
 	const urlSlugListing = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING;
34 34
 	/**
35
-	*	Define the url edition slug used in the current class
36
-	*/
35
+	 *	Define the url edition slug used in the current class
36
+	 */
37 37
 	const urlSlugEdition = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING;
38 38
 	/**
39
-	*	Define the current entity code
40
-	*/
39
+	 *	Define the current entity code
40
+	 */
41 41
 	const currentPageCode = 'attributes_unit';
42 42
 	/**
43
-	*	Define the page title
44
-	*/
43
+	 *	Define the page title
44
+	 */
45 45
 	const pageContentTitle = 'Attributes unit';
46 46
 	/**
47
-	*	Define the page title when adding an attribute
48
-	*/
47
+	 *	Define the page title when adding an attribute
48
+	 */
49 49
 	const pageAddingTitle = 'Add an unit';
50 50
 	/**
51
-	*	Define the page title when editing an attribute
52
-	*/
51
+	 *	Define the page title when editing an attribute
52
+	 */
53 53
 	const pageEditingTitle = 'Unit "%s" edit';
54 54
 	/**
55
-	*	Define the page title when editing an attribute
56
-	*/
55
+	 *	Define the page title when editing an attribute
56
+	 */
57 57
 	const pageTitle = 'Attributes unit list';
58 58
 
59 59
 	/**
60
-	*	Define the path to page main icon
61
-	*/
60
+	 *	Define the path to page main icon
61
+	 */
62 62
 	public $pageIcon = '';
63 63
 	/**
64
-	*	Define the message to output after an action
65
-	*/
64
+	 *	Define the message to output after an action
65
+	 */
66 66
 	public $pageMessage = '';
67 67
 
68 68
 	/**
69
-	*	Get the url listing slug of the current class
70
-	*
71
-	*	@return string The table of the class
72
-	*/
69
+	 *	Get the url listing slug of the current class
70
+	 *
71
+	 *	@return string The table of the class
72
+	 */
73 73
 	function setMessage($message)
74 74
 	{
75 75
 		$this->pageMessage = $message;
76 76
 	}
77 77
 	/**
78
-	*	Get the url listing slug of the current class
79
-	*
80
-	*	@return string The table of the class
81
-	*/
78
+	 *	Get the url listing slug of the current class
79
+	 *
80
+	 *	@return string The table of the class
81
+	 */
82 82
 	public static function getListingSlug()
83 83
 	{
84 84
 		return self::urlSlugListing;
85 85
 	}
86 86
 	/**
87
-	*	Get the url edition slug of the current class
88
-	*
89
-	*	@return string The table of the class
90
-	*/
87
+	 *	Get the url edition slug of the current class
88
+	 *
89
+	 *	@return string The table of the class
90
+	 */
91 91
 	public static function getEditionSlug()
92 92
 	{
93 93
 		return self::urlSlugEdition;
94 94
 	}
95 95
 	/**
96
-	*	Get the database table of the current class
97
-	*
98
-	*	@return string The table of the class
99
-	*/
96
+	 *	Get the database table of the current class
97
+	 *
98
+	 *	@return string The table of the class
99
+	 */
100 100
 	public static function getDbTable()
101 101
 	{
102 102
 		return self::dbTable;
103 103
 	}
104 104
 
105 105
 	/**
106
-	*	Define the title of the page
107
-	*
108
-	*	@return string $title The title of the page looking at the environnement
109
-	*/
106
+	 *	Define the title of the page
107
+	 *
108
+	 *	@return string $title The title of the page looking at the environnement
109
+	 */
110 110
 	function pageTitle()
111 111
 	{
112 112
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : '';
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	*	Define the different message and action after an action is send through the element interface
137
-	*/
136
+	 *	Define the different message and action after an action is send through the element interface
137
+	 */
138 138
 	function elementAction()
139 139
 	{
140 140
 		global $wpdb, $initialEavData;
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	/**
266
-	*	Return the list page content, containing the table that present the item list
267
-	*
268
-	*	@return string $listItemOutput The html code that output the item list
269
-	*/
266
+	 *	Return the list page content, containing the table that present the item list
267
+	 *
268
+	 *	@return string $listItemOutput The html code that output the item list
269
+	 */
270 270
 	public static function elementList()
271 271
 	{
272 272
 		$listItemOutput = '';
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 		return $listItemOutput;
388 388
 	}
389 389
 	/**
390
-	*	Return the page content to add a new item
391
-	*
392
-	*	@return string The html code that output the interface for adding a nem item
393
-	*/
390
+	 *	Return the page content to add a new item
391
+	 *
392
+	 *	@return string The html code that output the interface for adding a nem item
393
+	 */
394 394
 	public static function elementEdition($itemToEdit = ''){
395 395
 		global $attribute_displayed_field; global $wpdb;
396 396
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 		return $the_form;
485 485
 	}
486 486
 	/**
487
-	*	Return the different button to save the item currently being added or edited
488
-	*
489
-	*	@return string $currentPageButton The html output code with the different button to add to the interface
490
-	*/
487
+	 *	Return the different button to save the item currently being added or edited
488
+	 *
489
+	 *	@return string $currentPageButton The html output code with the different button to add to the interface
490
+	 */
491 491
 	function getPageFormButton($element_id = 0)
492 492
 	{
493 493
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add';
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	*	Get the existing attribute list into database
519
-	*
520
-	*	@param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned
521
-	*	@param string $element_status optionnal The status of element to get into database. Default is set to valid element
522
-	*	@param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
523
-	*
524
-	*	@return object $element_list A wordpress database object containing the attribute list
525
-	*/
518
+	 *	Get the existing attribute list into database
519
+	 *
520
+	 *	@param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned
521
+	 *	@param string $element_status optionnal The status of element to get into database. Default is set to valid element
522
+	 *	@param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
523
+	 *
524
+	 *	@return object $element_list A wordpress database object containing the attribute list
525
+	 */
526 526
 	public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){
527 527
 		global $wpdb;
528 528
 		$element_list = array();
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 	}
555 555
 
556 556
 	/**
557
-	*
558
-	*/
557
+	 *
558
+	 */
559 559
 	public static function get_unit_list_for_group($group_id){
560 560
 		global $wpdb;
561 561
 		$unit_list_for_group = '';
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 		return $unit_list_for_group;
570 570
 	}
571 571
 	/**
572
-	*
573
-	*/
572
+	 *
573
+	 */
574 574
 	public static function get_default_unit_for_group($group_id){
575 575
 		global $wpdb;
576 576
 		$default_unit_for_group = '';
@@ -583,10 +583,10 @@  discard block
 block discarded – undo
583 583
 	}
584 584
 
585 585
 	/**
586
-	*	Get the unit group existing list in database
587
-	*
588
-	*	@return object $attribute_unit_group_list The list of existing unit group
589
-	*/
586
+	 *	Get the unit group existing list in database
587
+	 *
588
+	 *	@return object $attribute_unit_group_list The list of existing unit group
589
+	 */
590 590
 	public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){
591 591
 		global $wpdb;
592 592
 		$element_list = array();
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 		// return $attribute_unit_group_list;
620 620
 	}
621 621
 	/**
622
-	*	Return the list page content, containing the table that present the item list
623
-	*
624
-	*	@return string $listItemOutput The html code that output the item list
625
-	*/
622
+	 *	Return the list page content, containing the table that present the item list
623
+	 *
624
+	 *	@return string $listItemOutput The html code that output the item list
625
+	 */
626 626
 	public static function unit_group_list(){
627 627
 		$listItemOutput = '';
628 628
 
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 		return $listItemOutput;
735 735
 	}
736 736
 	/**
737
-	*	Return the page content to add a new item
738
-	*
739
-	*	@return string The html code that output the interface for adding a nem item
740
-	*/
737
+	 *	Return the page content to add a new item
738
+	 *
739
+	 *	@return string The html code that output the interface for adding a nem item
740
+	 */
741 741
 	public static function unit_group_edition($itemToEdit = ''){
742 742
 		global $attribute_displayed_field;
743 743
 		$dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
Please login to merge, or discard this patch.
Braces   +48 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
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' ) ) {
@@ -119,13 +121,11 @@  discard block
 block discarded – undo
119 121
 			{
120 122
 				$editedItem = self::getElement($objectInEdition);
121 123
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . '&nbsp;(' . $editedItem->code . ')');
122
-			}
123
-			elseif($action == 'add')
124
+			} elseif($action == 'add')
124 125
 			{
125 126
 				$title = __(self::pageAddingTitle, 'wpshop');
126 127
 			}
127
-		}
128
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($_GET['page'] == self::getEditionSlug()))
128
+		} elseif((self::getEditionSlug() != self::getListingSlug()) && ($_GET['page'] == self::getEditionSlug()))
129 129
 		{
130 130
 			$title = __(self::pageAddingTitle, 'wpshop');
131 131
 		}
@@ -150,8 +150,7 @@  discard block
 block discarded – undo
150 150
 		{
151 151
 			$editedElement = self::getElement($saveditem);
152 152
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
153
-		}
154
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0))
153
+		} elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0))
155 154
 		{
156 155
 			$editedElement = self::getElement($saveditem, "'deleted'");
157 156
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
@@ -172,32 +171,27 @@  discard block
 block discarded – undo
172 171
 					if(current_user_can('wpshop_delete_attributes'))
173 172
 					{
174 173
 						$_REQUEST[self::getDbTable()]['status'] = 'deleted';
175
-					}
176
-					else
174
+					} else
177 175
 					{
178 176
 						$actionResult = 'userNotAllowedForActionDelete';
179 177
 					}
180 178
 				}
181 179
 				$actionResult = wpshop_database::update($_REQUEST[self::getDbTable()], $id, self::getDbTable());
182
-			}
183
-			else
180
+			} else
184 181
 			{
185 182
 				$actionResult = 'userNotAllowedForActionEdit';
186 183
 			}
187
-		}
188
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
184
+		} elseif(($pageAction != '') && (($pageAction == 'delete'))){
189 185
 			if(current_user_can('wpshop_delete_attributes'))
190 186
 			{
191 187
 				$_REQUEST[self::getDbTable()]['last_update_date'] = date('Y-m-d H:i:s');
192 188
 				$_REQUEST[self::getDbTable()]['status'] = 'deleted';
193 189
 				$actionResult = wpshop_database::update($_REQUEST[self::getDbTable()], $id, self::getDbTable());
194
-			}
195
-			else
190
+			} else
196 191
 			{
197 192
 				$actionResult = 'userNotAllowedForActionDelete';
198 193
 			}
199
-		}
200
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
194
+		} elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
201 195
 			if(current_user_can('wpshop_add_attributes')){
202 196
 				$_REQUEST[self::getDbTable()]['creation_date'] = date('Y-m-d H:i:s');
203 197
 				if(trim($_REQUEST[self::getDbTable()]['code']) == ''){
@@ -210,8 +204,7 @@  discard block
 block discarded – undo
210 204
 				}
211 205
 				$actionResult = wpshop_database::save($_REQUEST[self::getDbTable()], self::getDbTable());
212 206
 				$id = $wpdb->insert_id;
213
-			}
214
-			else{
207
+			} else{
215 208
 				$actionResult = 'userNotAllowedForActionAdd';
216 209
 			}
217 210
 		}
@@ -229,8 +222,7 @@  discard block
 block discarded – undo
229 222
 				{
230 223
 					$pageMessage .= '<br/>' . $wpdb->last_error;
231 224
 				}
232
-			}
233
-			elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate'))
225
+			} elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate'))
234 226
 			{/*	CHANGE HERE FOR SPECIFIC CASE	*/
235 227
 				/*****************************************************************************************************************/
236 228
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				******************/
@@ -243,17 +235,14 @@  discard block
 block discarded – undo
243 235
 				if(($pageAction == 'edit') || ($pageAction == 'save'))
244 236
 				{
245 237
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
246
-				}
247
-				elseif($pageAction == 'add')
238
+				} elseif($pageAction == 'add')
248 239
 				{
249 240
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
250
-				}
251
-				elseif($pageAction == 'delete')
241
+				} elseif($pageAction == 'delete')
252 242
 				{
253 243
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
254 244
 				}
255
-			}
256
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
245
+			} elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
257 246
 			{
258 247
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
259 248
 			}
@@ -302,8 +291,7 @@  discard block
 block discarded – undo
302 291
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
303 292
 					$subRowActions .= '
304 293
 		<a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" >' . __('Edit', 'wpshop') . '</a>';
305
-				}
306
-				elseif(current_user_can('wpshop_view_attributes_unit'))
294
+				} elseif(current_user_can('wpshop_view_attributes_unit'))
307 295
 				{
308 296
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
309 297
 				}
@@ -329,8 +317,7 @@  discard block
 block discarded – undo
329 317
 
330 318
 				$line++;
331 319
 			}
332
-		}
333
-		else{
320
+		} else{
334 321
 			unset($tableRowValue);
335 322
 			$tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop'));
336 323
 			$tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => '');
@@ -411,8 +398,7 @@  discard block
 block discarded – undo
411 398
 			$currentFieldValue = $input_def['value'];
412 399
 			if(is_object($editedItem)){
413 400
 				$currentFieldValue = $editedItem->{$input_def['name']};
414
-			}
415
-			elseif(($pageAction != '') && ($requestFormValue != '')){
401
+			} elseif(($pageAction != '') && ($requestFormValue != '')){
416 402
 				$currentFieldValue = $requestFormValue;
417 403
 			}
418 404
 
@@ -444,8 +430,7 @@  discard block
 block discarded – undo
444 430
 				</div>';
445 431
 
446 432
 
447
-			}
448
-			else{
433
+			} else{
449 434
 				$the_form_content_hidden .= '
450 435
 	' . $the_input;
451 436
 			}
@@ -499,8 +484,7 @@  discard block
 block discarded – undo
499 484
 			{
500 485
 				$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
501 486
 			}
502
-		}
503
-		elseif(current_user_can('wpshop_edit_attributes'))
487
+		} elseif(current_user_can('wpshop_edit_attributes'))
504 488
 		{
505 489
 			$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />';
506 490
 		}
@@ -545,8 +529,7 @@  discard block
 block discarded – undo
545 529
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
546 530
 		if($element_id == ''){
547 531
 			$element_list = $wpdb->get_results($query);
548
-		}
549
-		else{
532
+		} else{
550 533
 			$element_list = $wpdb->get_row($query);
551 534
 		}
552 535
 
@@ -606,10 +589,11 @@  discard block
 block discarded – undo
606 589
 		);
607 590
 
608 591
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
609
-		if($element_id == '')
610
-			$element_list = $wpdb->get_results($query);
611
-		else
612
-			$element_list = $wpdb->get_row($query);
592
+		if($element_id == '') {
593
+					$element_list = $wpdb->get_results($query);
594
+		} else {
595
+					$element_list = $wpdb->get_row($query);
596
+		}
613 597
 
614 598
 		return $element_list;
615 599
 
@@ -653,8 +637,7 @@  discard block
 block discarded – undo
653 637
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
654 638
 					$subRowActions .= '
655 639
 		<a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" >' . __('Edit', 'wpshop') . '</a>';
656
-				}
657
-				elseif(current_user_can('wpshop_view_attributes_unit_group'))
640
+				} elseif(current_user_can('wpshop_view_attributes_unit_group'))
658 641
 				{
659 642
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
660 643
 				}
@@ -678,8 +661,7 @@  discard block
 block discarded – undo
678 661
 
679 662
 				$line++;
680 663
 			}
681
-		}
682
-		else{
664
+		} else{
683 665
 			unset($tableRowValue);
684 666
 			$tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop'));
685 667
 			$tableRows[] = $tableRowValue;
@@ -756,8 +738,7 @@  discard block
 block discarded – undo
756 738
 			$currentFieldValue = $input_def['value'];
757 739
 			if(is_object($editedItem)){
758 740
 				$currentFieldValue = $editedItem->{$input_def['name']};
759
-			}
760
-			elseif(($pageAction != '') && ($requestFormValue != '')){
741
+			} elseif(($pageAction != '') && ($requestFormValue != '')){
761 742
 				$currentFieldValue = $requestFormValue;
762 743
 			}
763 744
 
@@ -782,12 +763,10 @@  discard block
 block discarded – undo
782 763
 	</div>';
783 764
 				if(substr($input_def['name'], 0, 3) == 'is_'){
784 765
 					$the_form_option_content .= $input;
785
-				}
786
-				else{
766
+				} else{
787 767
 					$the_form_general_content .= $input;
788 768
 				}
789
-			}
790
-			else{
769
+			} else{
791 770
 				$the_form_content_hidden .= '
792 771
 	' . $the_input;
793 772
 			}
@@ -841,8 +820,7 @@  discard block
 block discarded – undo
841 820
 			foreach ( $currencies as $currency) {
842 821
 				$currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>';
843 822
 			}
844
-		}
845
-		else {
823
+		} else {
846 824
 			foreach($wpshop_shop_currencies as $k => $v) {
847 825
 				$currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>';
848 826
 			}
@@ -874,14 +852,16 @@  discard block
 block discarded – undo
874 852
 	public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) {
875 853
 		$unit = self::get_default_unit_attribute( $attribute_code );
876 854
 		
877
-		if(empty($unit))
878
-			return null;
855
+		if(empty($unit)) {
856
+					return null;
857
+		}
879 858
 		
880 859
 		$post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true);
881 860
 
882 861
 		/** Si on trouve une unité */
883
-		if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code]))
884
-			$unit->_default_unit = $post_meta['unit'][$attribute_code];
862
+		if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) {
863
+					$unit->_default_unit = $post_meta['unit'][$attribute_code];
864
+		}
885 865
 
886 866
 		return $unit;
887 867
 	}
@@ -895,8 +875,9 @@  discard block
 block discarded – undo
895 875
 	public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) {
896 876
 		$unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code);
897 877
 		
898
-		if(empty($unit))
899
-			return null;
878
+		if(empty($unit)) {
879
+					return null;
880
+		}
900 881
 		
901 882
 		echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit);
902 883
 	}
@@ -912,8 +893,9 @@  discard block
 block discarded – undo
912 893
 		global $wpdb;
913 894
 		
914 895
 		/** Si pas d'unité ou de groupe, null */
915
-		if(0 === $unit_id || 0 === $group_id)
916
-			return null;
896
+		if(0 === $unit_id || 0 === $group_id) {
897
+					return null;
898
+		}
917 899
 		
918 900
 		return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) );
919 901
 	}
@@ -929,8 +911,9 @@  discard block
 block discarded – undo
929 911
 		global $wpdb;
930 912
 		
931 913
 		/** Si pas d'unité ou de groupe, null */
932
-		if(0 === $unit_id || 0 === $group_id)
933
-			return null;
914
+		if(0 === $unit_id || 0 === $group_id) {
915
+					return null;
916
+		}
934 917
 		
935 918
 		return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) );
936 919
 	}
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -112,20 +112,20 @@  discard block
 block discarded – undo
112 112
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : '';
113 113
 		$objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : '';
114 114
 
115
-		$title = __(self::pageTitle, 'wpshop' );
116
-		if($action != '')
115
+		$title = __(self::pageTitle, 'wpshop');
116
+		if ($action != '')
117 117
 		{
118
-			if(($action == 'edit') || ($action == 'delete'))
118
+			if (($action == 'edit') || ($action == 'delete'))
119 119
 			{
120 120
 				$editedItem = self::getElement($objectInEdition);
121 121
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . '&nbsp;(' . $editedItem->code . ')');
122 122
 			}
123
-			elseif($action == 'add')
123
+			elseif ($action == 'add')
124 124
 			{
125 125
 				$title = __(self::pageAddingTitle, 'wpshop');
126 126
 			}
127 127
 		}
128
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($_GET['page'] == self::getEditionSlug()))
128
+		elseif ((self::getEditionSlug() != self::getListingSlug()) && ($_GET['page'] == self::getEditionSlug()))
129 129
 		{
130 130
 			$title = __(self::pageAddingTitle, 'wpshop');
131 131
 		}
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 		/****************************************************************************/
147 147
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add';
148 148
 		$saveditem = isset($_REQUEST['saveditem']) ? wpshop_tools::varSanitizer($_REQUEST['saveditem']) : '';
149
-		if(($action != '') && ($action == 'saveok') && ($saveditem > 0))
149
+		if (($action != '') && ($action == 'saveok') && ($saveditem > 0))
150 150
 		{
151 151
 			$editedElement = self::getElement($saveditem);
152 152
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
153 153
 		}
154
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0))
154
+		elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0))
155 155
 		{
156 156
 			$editedElement = self::getElement($saveditem, "'deleted'");
157 157
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 		/*************************************************************************/
164 164
 		$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : '';
165 165
 		$id = isset($_REQUEST[self::getDbTable()]['id']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable()]['id']) : '';
166
-		if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){
167
-			if(current_user_can('wpshop_edit_attributes'))
166
+		if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) {
167
+			if (current_user_can('wpshop_edit_attributes'))
168 168
 			{
169 169
 				$_REQUEST[self::getDbTable()]['last_update_date'] = date('Y-m-d H:i:s');
170
-				if($pageAction == 'delete')
170
+				if ($pageAction == 'delete')
171 171
 				{
172
-					if(current_user_can('wpshop_delete_attributes'))
172
+					if (current_user_can('wpshop_delete_attributes'))
173 173
 					{
174 174
 						$_REQUEST[self::getDbTable()]['status'] = 'deleted';
175 175
 					}
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 				$actionResult = 'userNotAllowedForActionEdit';
186 186
 			}
187 187
 		}
188
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
189
-			if(current_user_can('wpshop_delete_attributes'))
188
+		elseif (($pageAction != '') && (($pageAction == 'delete'))) {
189
+			if (current_user_can('wpshop_delete_attributes'))
190 190
 			{
191 191
 				$_REQUEST[self::getDbTable()]['last_update_date'] = date('Y-m-d H:i:s');
192 192
 				$_REQUEST[self::getDbTable()]['status'] = 'deleted';
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
 				$actionResult = 'userNotAllowedForActionDelete';
198 198
 			}
199 199
 		}
200
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
201
-			if(current_user_can('wpshop_add_attributes')){
200
+		elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) {
201
+			if (current_user_can('wpshop_add_attributes')) {
202 202
 				$_REQUEST[self::getDbTable()]['creation_date'] = date('Y-m-d H:i:s');
203
-				if(trim($_REQUEST[self::getDbTable()]['code']) == ''){
203
+				if (trim($_REQUEST[self::getDbTable()]['code']) == '') {
204 204
 					$_REQUEST[self::getDbTable()]['code'] = $_REQUEST[self::getDbTable()]['frontend_label'];
205 205
 				}
206 206
 				$_REQUEST[self::getDbTable()]['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $_REQUEST[self::getDbTable()]['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation'));
207 207
 				$code_exists = self::getElement($_REQUEST[self::getDbTable()]['code'], "'valid', 'moderated', 'deleted'", 'code');
208
-				if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){
208
+				if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) {
209 209
 					$_REQUEST[self::getDbTable()]['code'] = $_REQUEST[self::getDbTable()]['code'] . '_' . (count($code_exists) + 1);
210 210
 				}
211 211
 				$actionResult = wpshop_database::save($_REQUEST[self::getDbTable()], self::getDbTable());
212 212
 				$id = $wpdb->insert_id;
213 213
 			}
214
-			else{
214
+			else {
215 215
 				$actionResult = 'userNotAllowedForActionAdd';
216 216
 			}
217 217
 		}
@@ -221,16 +221,16 @@  discard block
 block discarded – undo
221 221
 		/************		CHANGE THE FIELD NAME TO TAKE TO DISPLAY				*************/
222 222
 		/************		CHANGE ERROR MESSAGE FOR SPECIFIC CASE					*************/
223 223
 		/****************************************************************************/
224
-		if($actionResult != ''){
224
+		if ($actionResult != '') {
225 225
 			$elementIdentifierForMessage = '<span class="bold" >' . $_REQUEST[self::getDbTable()]['frontend_label'] . '</span>';
226 226
 			if ($actionResult == 'error') {
227 227
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage);
228
-				if(WPSHOP_DEBUG_MODE)
228
+				if (WPSHOP_DEBUG_MODE)
229 229
 				{
230 230
 					$pageMessage .= '<br/>' . $wpdb->last_error;
231 231
 				}
232 232
 			}
233
-			elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate'))
233
+			elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate'))
234 234
 			{/*	CHANGE HERE FOR SPECIFIC CASE	*/
235 235
 				/*****************************************************************************************************************/
236 236
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				******************/
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 				/*************************			GENERIC				****************************/
241 241
 				/***********************************************************************************/
242 242
 				$pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage);
243
-				if(($pageAction == 'edit') || ($pageAction == 'save'))
243
+				if (($pageAction == 'edit') || ($pageAction == 'save'))
244 244
 				{
245 245
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
246 246
 				}
247
-				elseif($pageAction == 'add')
247
+				elseif ($pageAction == 'add')
248 248
 				{
249 249
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
250 250
 				}
251
-				elseif($pageAction == 'delete')
251
+				elseif ($pageAction == 'delete')
252 252
 				{
253 253
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
254 254
 				}
255 255
 			}
256
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
256
+			elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete'))
257 257
 			{
258 258
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
259 259
 			}
@@ -285,31 +285,31 @@  discard block
 block discarded – undo
285 285
 
286 286
 		$line = 0;
287 287
 		$elementList = self::getElement();
288
-		if(is_array($elementList) && (count($elementList) > 0)){
289
-			foreach($elementList as $element)
288
+		if (is_array($elementList) && (count($elementList) > 0)) {
289
+			foreach ($elementList as $element)
290 290
 			{
291 291
 				$tableRowsId[$line] = self::getDbTable() . '_' . $element->id;
292 292
 
293 293
 				$elementLabel = __($element->name, 'wpshop');
294 294
 				$subRowActions = '';
295 295
 				$attributeSlugUrl = self::getListingSlug();
296
-				if(current_user_can('wpshop_add_attributes_unit'))
296
+				if (current_user_can('wpshop_add_attributes_unit'))
297 297
 				{
298 298
 					$attributeSlugUrl = self::getEditionSlug();
299 299
 				}
300
-				if(current_user_can('wpshop_edit_attributes_unit'))
300
+				if (current_user_can('wpshop_edit_attributes_unit'))
301 301
 				{
302 302
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
303 303
 					$subRowActions .= '
304 304
 		<a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" >' . __('Edit', 'wpshop') . '</a>';
305 305
 				}
306
-				elseif(current_user_can('wpshop_view_attributes_unit'))
306
+				elseif (current_user_can('wpshop_view_attributes_unit'))
307 307
 				{
308 308
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
309 309
 				}
310
-				if(current_user_can('wpshop_delete_attributes_unit'))
310
+				if (current_user_can('wpshop_delete_attributes_unit'))
311 311
 				{
312
-					if($subRowActions != '')
312
+					if ($subRowActions != '')
313 313
 					{
314 314
 						$subRowActions .= '&nbsp;|&nbsp;';
315 315
 					}
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 				$line++;
331 331
 			}
332 332
 		}
333
-		else{
333
+		else {
334 334
 			unset($tableRowValue);
335 335
 			$tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop'));
336 336
 			$tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => '');
337 337
 			$tableRowValue[] = array('class' => self::currentPageCode . '_code_cell', 'value' => '');
338 338
 			$tableRows[] = $tableRowValue;
339 339
 		}
340
-		if(current_user_can('wpshop_add_attributes_unit')){
340
+		if (current_user_can('wpshop_add_attributes_unit')) {
341 341
 			$listItemOutput .= '
342 342
 <input type="button" value="' . __('Add an unit', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit" id="add_attribute_unit" />';
343 343
 		}
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 	wpshop(document).ready(function(){
347 347
 		jQuery("#' . $tableId . '").dataTable();
348 348
 		jQuery("#wpshop_unit_group_list_tab").show();';
349
-		if(current_user_can('wpshop_delete_attributes_unit')){
349
+		if (current_user_can('wpshop_delete_attributes_unit')) {
350 350
 			$listItemOutput .= '
351 351
 		wpshop(".delete_attribute_unit").click(function(){
352
-			if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop')  .' ?"))){
352
+			if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop') . ' ?"))){
353 353
 				wpshop("#wpshop_unit_list").load(ajaxurl,{
354 354
 					"action": "wps_attribute_unit_delete",
355 355
 					"elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_", "")
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			}
358 358
 		});';
359 359
 		}
360
-		if(current_user_can('wpshop_edit_attributes_unit')){
360
+		if (current_user_can('wpshop_edit_attributes_unit')) {
361 361
 			$listItemOutput .= '
362 362
 		jQuery(".edit_attribute_unit").click(function(){
363 363
 			jQuery("#wpshop_unit_list").load(ajaxurl,{
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 			});
367 367
 		});';
368 368
 		}
369
-		if(current_user_can('wpshop_add_attributes_unit')){
369
+		if (current_user_can('wpshop_add_attributes_unit')) {
370 370
 			$listItemOutput .= '
371 371
 		jQuery("#add_attribute_unit").click(function(){
372 372
 			jQuery("#wpshop_unit_list").load(ajaxurl,{
@@ -385,33 +385,33 @@  discard block
 block discarded – undo
385 385
 	*
386 386
 	*	@return string The html code that output the interface for adding a nem item
387 387
 	*/
388
-	public static function elementEdition($itemToEdit = ''){
388
+	public static function elementEdition($itemToEdit = '') {
389 389
 		global $attribute_displayed_field; global $wpdb;
390 390
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
391 391
 
392 392
 		$editedItem = '';
393 393
 		$_REQUEST['action'] = 'save_new_attribute_unit';
394
-		if($itemToEdit != ''){
394
+		if ($itemToEdit != '') {
395 395
 			$editedItem = self::getElement($itemToEdit);
396 396
 			$_REQUEST['action'] = 'update_attribute_unit';
397 397
 		}
398
-		$query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = ' .get_option('wpshop_shop_default_currency'). '', '');
398
+		$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = ' . get_option('wpshop_shop_default_currency') . '', '');
399 399
  		$default_unit = $wpdb->get_var($query);
400 400
 
401 401
 		$the_form_content_hidden = $the_form_general_content = $the_form_option_content = '';
402
-		foreach($dbFieldList as $input_key => $input_def){
402
+		foreach ($dbFieldList as $input_key => $input_def) {
403 403
 			$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : '';
404 404
 			$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : '';
405 405
 			$currentFieldValue = $input_def['value'];
406
-			if(is_object($editedItem)){
406
+			if (is_object($editedItem)) {
407 407
 				$currentFieldValue = $editedItem->{$input_def['name']};
408 408
 			}
409
-			elseif(($pageAction != '') && ($requestFormValue != '')){
409
+			elseif (($pageAction != '') && ($requestFormValue != '')) {
410 410
 				$currentFieldValue = $requestFormValue;
411 411
 			}
412 412
 
413 413
 			$input_def['value'] = $currentFieldValue;
414
-			if($input_def['name'] == 'group_id'){
414
+			if ($input_def['name'] == 'group_id') {
415 415
 				$attribute_unit_group_list = self::get_unit_group();
416 416
 				$input_def['possible_value'] = $attribute_unit_group_list;
417 417
 				$input_def['type'] = 'select';
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 			$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
422 422
 
423 423
 
424
-			if($input_def['type'] != 'hidden'){
424
+			if ($input_def['type'] != 'hidden') {
425 425
 				$label = 'for="' . $input_def['name'] . '"';
426
-				if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){
426
+				if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) {
427 427
 					$label = '';
428 428
 				}
429 429
 
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 						<label ' . $label . ' >' . __($input_def['name'], 'wpshop') . '</label>
434 434
 					</div>
435 435
 					<div class="wpshop_form_input wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_input alignleft" >
436
-						' . $the_input . ' ' .( ($input_def['name'] == 'change_rate') ? $default_unit : ''). '
436
+						' . $the_input . ' ' . (($input_def['name'] == 'change_rate') ? $default_unit : '') . '
437 437
 					</div>
438 438
 				</div>';
439 439
 
440 440
 
441 441
 			}
442
-			else{
442
+			else {
443 443
 				$the_form_content_hidden .= '
444 444
 	' . $the_input;
445 445
 			}
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 		$the_form = '
449 449
 <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="' . admin_ajax() . '" >
450 450
 ' . wpshop_form::form_input('action', 'action', $_REQUEST['action'], 'hidden') . '
451
-' . wpshop_form::form_input('post', 'post', 'true' , 'hidden') . '
452
-' . wpshop_form::form_input('elementCode', 'elementCode', 'attribute_unit_management' , 'hidden') . '
453
-' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . '
454
-	' . $the_form_content_hidden .'' . $the_form_general_content . '
451
+' . wpshop_form::form_input('post', 'post', 'true', 'hidden') . '
452
+' . wpshop_form::form_input('elementCode', 'elementCode', 'attribute_unit_management', 'hidden') . '
453
+' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . '
454
+	' . $the_form_content_hidden . '' . $the_form_general_content . '
455 455
 	<input type="button" value="' . __('Back', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_edition" id="cancel_unit_edition" />
456 456
 	<input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit" id="save_new_unit" />
457 457
 </form>
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 		$action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add';
486 486
 		$currentPageButton = '';
487 487
 
488
-		if($action == 'add')
488
+		if ($action == 'add')
489 489
 		{
490
-			if(current_user_can('wpshop_add_attributes'))
490
+			if (current_user_can('wpshop_add_attributes'))
491 491
 			{
492 492
 				$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
493 493
 			}
494 494
 		}
495
-		elseif(current_user_can('wpshop_edit_attributes'))
495
+		elseif (current_user_can('wpshop_edit_attributes'))
496 496
 		{
497 497
 			$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />';
498 498
 		}
499
-		if(current_user_can('wpshop_delete_attributes') && ($action != 'add'))
499
+		if (current_user_can('wpshop_delete_attributes') && ($action != 'add'))
500 500
 		{
501 501
 			$currentPageButton .= '<input type="button" class="button-primary" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
502 502
 		}
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
 	*
516 516
 	*	@return object $element_list A wordpress database object containing the attribute list
517 517
 	*/
518
-	public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){
518
+	public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') {
519 519
 		global $wpdb;
520 520
 		$element_list = array();
521 521
 		$moreQuery = "";
522
-		$moreQueryArgs = array( 1, );
522
+		$moreQueryArgs = array(1,);
523 523
 
524
-		if($element_id != ''){
524
+		if ($element_id != '') {
525 525
 			$moreQuery = "
526 526
 			AND CURRENT_ELEMENT." . $field_to_search . " = %s ";
527 527
 			$moreQueryArgs[] = $element_id;
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 		"SELECT CURRENT_ELEMENT.*, UNIT_GROUP.name as group_name
532 532
 		FROM " . self::getDbTable() . " AS CURRENT_ELEMENT
533 533
 			LEFT JOIN " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS UNIT_GROUP ON (UNIT_GROUP.id = CURRENT_ELEMENT.group_id)
534
-		WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs
534
+		WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs
535 535
 		);
536 536
 
537 537
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
538
-		if($element_id == ''){
538
+		if ($element_id == '') {
539 539
 			$element_list = $wpdb->get_results($query);
540 540
 		}
541
-		else{
541
+		else {
542 542
 			$element_list = $wpdb->get_row($query);
543 543
 		}
544 544
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	/**
549 549
 	*
550 550
 	*/
551
-	public static function get_unit_list_for_group($group_id){
551
+	public static function get_unit_list_for_group($group_id) {
552 552
 		global $wpdb;
553 553
 		$unit_list_for_group = '';
554 554
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	/**
564 564
 	*
565 565
 	*/
566
-	public static function get_default_unit_for_group($group_id){
566
+	public static function get_default_unit_for_group($group_id) {
567 567
 		global $wpdb;
568 568
 		$default_unit_for_group = '';
569 569
 
@@ -579,13 +579,13 @@  discard block
 block discarded – undo
579 579
 	*
580 580
 	*	@return object $attribute_unit_group_list The list of existing unit group
581 581
 	*/
582
-	public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){
582
+	public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') {
583 583
 		global $wpdb;
584 584
 		$element_list = array();
585 585
 		$moreQuery = "";
586
-		$moreQueryArgs = array( 1, );
586
+		$moreQueryArgs = array(1,);
587 587
 
588
-		if($element_id != ''){
588
+		if ($element_id != '') {
589 589
 			$moreQuery = "
590 590
 			AND CURRENT_ELEMENT." . $field_to_search . " = %d ";
591 591
 			$moreQueryArgs[] = $element_id;
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
 		$query = $wpdb->prepare(
595 595
 		"SELECT CURRENT_ELEMENT.*
596 596
 		FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS CURRENT_ELEMENT
597
-		WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs
597
+		WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs
598 598
 		);
599 599
 
600 600
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
601
-		if($element_id == '')
601
+		if ($element_id == '')
602 602
 			$element_list = $wpdb->get_results($query);
603 603
 		else
604 604
 			$element_list = $wpdb->get_row($query);
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	*
616 616
 	*	@return string $listItemOutput The html code that output the item list
617 617
 	*/
618
-	public static function unit_group_list(){
618
+	public static function unit_group_list() {
619 619
 		$listItemOutput = '';
620 620
 
621 621
 		/*	Start the table definition	*/
@@ -628,31 +628,31 @@  discard block
 block discarded – undo
628 628
 
629 629
 		$line = 0;
630 630
 		$elementList = self::get_unit_group();
631
-		if(is_array($elementList) && (count($elementList) > 0)){
632
-			foreach($elementList as $element)
631
+		if (is_array($elementList) && (count($elementList) > 0)) {
632
+			foreach ($elementList as $element)
633 633
 			{
634 634
 				$tableRowsId[$line] = self::getDbTable() . '_' . $element->id;
635 635
 
636 636
 				$elementLabel = __($element->name, 'wpshop');
637 637
 				$subRowActions = '';
638 638
 				$attributeSlugUrl = self::getListingSlug();
639
-				if(current_user_can('wpshop_add_attributes_unit_group'))
639
+				if (current_user_can('wpshop_add_attributes_unit_group'))
640 640
 				{
641 641
 					$attributeSlugUrl = self::getEditionSlug();
642 642
 				}
643
-				if(current_user_can('wpshop_edit_attributes_unit_group'))
643
+				if (current_user_can('wpshop_edit_attributes_unit_group'))
644 644
 				{
645 645
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
646 646
 					$subRowActions .= '
647 647
 		<a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" >' . __('Edit', 'wpshop') . '</a>';
648 648
 				}
649
-				elseif(current_user_can('wpshop_view_attributes_unit_group'))
649
+				elseif (current_user_can('wpshop_view_attributes_unit_group'))
650 650
 				{
651 651
 					$editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&amp;action=edit&amp;id=' . $element->id);
652 652
 				}
653
-				if(current_user_can('wpshop_delete_attributes_unit_group'))
653
+				if (current_user_can('wpshop_delete_attributes_unit_group'))
654 654
 				{
655
-					if($subRowActions != '')
655
+					if ($subRowActions != '')
656 656
 					{
657 657
 						$subRowActions .= '&nbsp;|&nbsp;';
658 658
 					}
@@ -671,12 +671,12 @@  discard block
 block discarded – undo
671 671
 				$line++;
672 672
 			}
673 673
 		}
674
-		else{
674
+		else {
675 675
 			unset($tableRowValue);
676 676
 			$tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop'));
677 677
 			$tableRows[] = $tableRowValue;
678 678
 		}
679
-		if(current_user_can('wpshop_add_attributes_unit_group')){
679
+		if (current_user_can('wpshop_add_attributes_unit_group')) {
680 680
 			$listItemOutput .= '
681 681
 <input type="button" value="' . __('Add an unit group', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit_group" id="add_attribute_unit_group" />';
682 682
 		}
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
 	wpshop(document).ready(function(){
686 686
 		jQuery("#' . $tableId . '").dataTable();
687 687
 		jQuery("#wpshop_unit_list_tab").show();';
688
-		if(current_user_can('wpshop_delete_attributes_unit_group')){
688
+		if (current_user_can('wpshop_delete_attributes_unit_group')) {
689 689
 			$listItemOutput .= '
690 690
 		wpshop(".delete_attribute_unit_group").click(function(){
691
-			if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop')  .' ?"))){
691
+			if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop') . ' ?"))){
692 692
 				wpshop("#wpshop_unit_group_list").load(ajaxurl, {
693 693
 					"action": "wps_attribute_group_unit_delete",
694 694
 					"elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_group_", "")
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 			}
697 697
 		});';
698 698
 		}
699
-		if(current_user_can('wpshop_edit_attributes_unit_group')){
699
+		if (current_user_can('wpshop_edit_attributes_unit_group')) {
700 700
 			$listItemOutput .= '
701 701
 		wpshop(".edit_attribute_unit_group").click(function(){
702 702
 			wpshop("#wpshop_unit_group_list").load(ajaxurl, {
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			});
706 706
 		});';
707 707
 		}
708
-		if(current_user_can('wpshop_add_attributes_unit_group')){
708
+		if (current_user_can('wpshop_add_attributes_unit_group')) {
709 709
 			$listItemOutput .= '
710 710
 		wpshop("#add_attribute_unit_group").click(function(){
711 711
 			wpshop("#wpshop_unit_group_list").load(ajaxurl, {
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	*
725 725
 	*	@return string The html code that output the interface for adding a nem item
726 726
 	*/
727
-	public static function unit_group_edition($itemToEdit = ''){
727
+	public static function unit_group_edition($itemToEdit = '') {
728 728
 		global $attribute_displayed_field;
729 729
 		$dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
730 730
 
@@ -736,14 +736,14 @@  discard block
 block discarded – undo
736 736
 		}*/
737 737
 
738 738
 		$the_form_content_hidden = $the_form_general_content = $the_form_option_content = '';
739
-		foreach($dbFieldList as $input_key => $input_def){
739
+		foreach ($dbFieldList as $input_key => $input_def) {
740 740
 			$pageAction = isset($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) : '';
741 741
 			$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : '';
742 742
 			$currentFieldValue = $input_def['value'];
743
-			if(is_object($editedItem)){
743
+			if (is_object($editedItem)) {
744 744
 				$currentFieldValue = $editedItem->{$input_def['name']};
745 745
 			}
746
-			elseif(($pageAction != '') && ($requestFormValue != '')){
746
+			elseif (($pageAction != '') && ($requestFormValue != '')) {
747 747
 				$currentFieldValue = $requestFormValue;
748 748
 			}
749 749
 
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
 			$input_def['value'] = __(str_replace("\\", "", $input_def['value']), 'wpshop');
753 753
 			$the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
754 754
 
755
-			if($input_def['type'] != 'hidden'){
755
+			if ($input_def['type'] != 'hidden') {
756 756
 				$label = 'for="' . $input_def['name'] . '"';
757
-				if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){
757
+				if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) {
758 758
 					$label = '';
759 759
 				}
760 760
 				$input = '
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 			' . $the_input . '
767 767
 		</div>
768 768
 	</div>';
769
-				if(substr($input_def['name'], 0, 3) == 'is_'){
769
+				if (substr($input_def['name'], 0, 3) == 'is_') {
770 770
 					$the_form_option_content .= $input;
771 771
 				}
772
-				else{
772
+				else {
773 773
 					$the_form_general_content .= $input;
774 774
 				}
775 775
 			}
776
-			else{
776
+			else {
777 777
 				$the_form_content_hidden .= '
778 778
 	' . $the_input;
779 779
 			}
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 		$the_form = '
783 783
 <form name="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" id="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" method="post" action="' . admin_url('admin-ajax.php') . '" >
784 784
 ' . wpshop_form::form_input('action', 'action', 'wps_attribute_group_unit_edit', 'hidden') . '
785
-' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . '
786
-	' . $the_form_content_hidden .'' . $the_form_general_content . '
785
+' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . '
786
+	' . $the_form_content_hidden . '' . $the_form_general_content . '
787 787
 	<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" />
788 788
 	<input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit_group" id="save_new_unit_group" />
789 789
 </form>
@@ -817,19 +817,19 @@  discard block
 block discarded – undo
817 817
 		$current_currency = get_option('wpshop_shop_default_currency');
818 818
 
819 819
 		$currencies_options = '';
820
-		if ( !empty ($currency_group) ) {
821
-			$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE group_id = %d', $currency_group);
820
+		if (!empty ($currency_group)) {
821
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id = %d', $currency_group);
822 822
 			$currencies = $wpdb->get_results($query);
823
-			foreach ( $currencies as $currency) {
824
-				$currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>';
823
+			foreach ($currencies as $currency) {
824
+				$currencies_options .= '<option value="' . $currency->id . '"' . (($currency->id == $current_currency) ? ' selected="selected"' : null) . '>' . $currency->name . ' (' . $currency->unit . ')</option>';
825 825
 			}
826 826
 		}
827 827
 		else {
828
-			foreach($wpshop_shop_currencies as $k => $v) {
829
-				$currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>';
828
+			foreach ($wpshop_shop_currencies as $k => $v) {
829
+				$currencies_options .= '<option value="' . $k . '"' . (($k == $current_currency) ? ' selected="selected"' : null) . '>' . $k . ' (' . $v . ')</option>';
830 830
 			}
831 831
 		}
832
-		return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >'.$currencies_options.'</select>';
832
+		return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >' . $currencies_options . '</select>';
833 833
 	}
834 834
 
835 835
 	/**
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		global $wpdb;
843 843
 
844 844
 		/** Get the _unit_group_id and _default_unit */
845
-		return $wpdb->get_row( $wpdb->prepare( 'SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array( $attribute_code ) ) );
845
+		return $wpdb->get_row($wpdb->prepare('SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array($attribute_code)));
846 846
 	}
847 847
 	
848 848
 	/**
@@ -854,15 +854,15 @@  discard block
 block discarded – undo
854 854
 	 * @return stdClass Object [_unit_group_id], [_default_unit]
855 855
 	 */
856 856
 	public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) {
857
-		$unit = self::get_default_unit_attribute( $attribute_code );
857
+		$unit = self::get_default_unit_attribute($attribute_code);
858 858
 		
859
-		if(empty($unit))
859
+		if (empty($unit))
860 860
 			return null;
861 861
 		
862 862
 		$post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true);
863 863
 
864 864
 		/** Si on trouve une unité */
865
-		if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code]))
865
+		if (!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code]))
866 866
 			$unit->_default_unit = $post_meta['unit'][$attribute_code];
867 867
 
868 868
 		return $unit;
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 	public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) {
878 878
 		$unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code);
879 879
 		
880
-		if(empty($unit))
880
+		if (empty($unit))
881 881
 			return null;
882 882
 		
883 883
 		echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit);
@@ -894,10 +894,10 @@  discard block
 block discarded – undo
894 894
 		global $wpdb;
895 895
 		
896 896
 		/** Si pas d'unité ou de groupe, null */
897
-		if(0 === $unit_id || 0 === $group_id)
897
+		if (0 === $unit_id || 0 === $group_id)
898 898
 			return null;
899 899
 		
900
-		return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) );
900
+		return $wpdb->get_var($wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id)));
901 901
 	}
902 902
 	
903 903
 	/**
@@ -911,9 +911,9 @@  discard block
 block discarded – undo
911 911
 		global $wpdb;
912 912
 		
913 913
 		/** Si pas d'unité ou de groupe, null */
914
-		if(0 === $unit_id || 0 === $group_id)
914
+		if (0 === $unit_id || 0 === $group_id)
915 915
 			return null;
916 916
 		
917
-		return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) );
917
+		return $wpdb->get_var($wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id)));
918 918
 	}
919 919
 }
920 920
\ No newline at end of file
Please login to merge, or discard this patch.
includes/librairies/eav/entities.class.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,6 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * The metabox content for entity type support section in entity edition page
90 90
 	 *
91
-	 * @param object $post The entity type being edited
92 91
 	 */
93 92
 	public static function wpshop_entity_support_section( $entity ) {
94 93
 		$output = '';
@@ -657,7 +656,7 @@  discard block
 block discarded – undo
657 656
 	/**
658 657
 	 * Define custom columns content display in post_type page for wpshop entities
659 658
 	 *
660
-	 * @param string $columns The default column for the post_type given in second parameter
659
+	 * @param string $column The default column for the post_type given in second parameter
661 660
 	 * @param integer $post_id The current post identifier to get information for display
662 661
 	 */
663 662
 	public static function custom_columns_content($column, $post_id) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 			'exclude_from_search'	=> true,
54 54
 			'capabilities'			=> array(
55 55
 				'edit_post' 			 => 'wpshop_view_dashboard',
56
-		        'edit_posts' 			 => 'wpshop_view_dashboard',
57
-		        'edit_others_posts' 	 => 'wpshop_view_dashboard',
58
-		        'publish_posts' 		 => 'wpshop_view_dashboard',
59
-		        'read_post' 			 => 'wpshop_view_dashboard',
60
-		        'read_private_posts' 	 => 'wpshop_view_dashboard',
56
+				'edit_posts' 			 => 'wpshop_view_dashboard',
57
+				'edit_others_posts' 	 => 'wpshop_view_dashboard',
58
+				'publish_posts' 		 => 'wpshop_view_dashboard',
59
+				'read_post' 			 => 'wpshop_view_dashboard',
60
+				'read_private_posts' 	 => 'wpshop_view_dashboard',
61 61
 				'delete_posts'			 => 'delete_product'
62 62
 			),
63 63
 		));
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	 * Save informations for current entity
420 420
 	 */
421 421
 	public static function save_entities_custom_informations( $post ) {
422
-       global $wpdb;
423
-       global $wpshop_account;
422
+	   global $wpdb;
423
+	   global $wpshop_account;
424 424
 		$post_id = !empty($_REQUEST['post_ID']) ? intval( wpshop_tools::varSanitizer($_REQUEST['post_ID']) ) : null;
425 425
 
426 426
 		if ( !empty($post_id) && empty($_POST['edit_other_thing']) || ( !empty($_REQUEST['post_ID']) && !(bool)$_POST['edit_other_thing'] && get_post_type($_REQUEST['post_ID']) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER  ) ) {
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		}
504 504
 
505 505
 		flush_rewrite_rules();
506
-    }
506
+	}
507 507
 
508 508
 
509 509
 	/**
Please login to merge, or discard this patch.
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * Define utilities to manage entities
4 4
  *
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 /*
12 12
  * Check if file is include. No direct access possible with file url
13 13
  */
14
-if ( !defined( 'WPSHOP_VERSION' ) ) {
15
-	die( __('Access is not allowed by this way', 'wpshop') );
14
+if (!defined('WPSHOP_VERSION')) {
15
+	die(__('Access is not allowed by this way', 'wpshop'));
16 16
 }
17 17
 
18 18
 /**
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	public static function create_wpshop_entities_type() {
32 32
 		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, array(
33 33
 			'labels' => array(
34
-				'name'					=> __( 'Entities', 'wpshop' ),
35
-				'singular_name' 		=> __( 'Entity', 'wpshop' ),
36
-				'add_new_item' 			=> __( 'Add new entity', 'wpshop' ),
37
-				'add_new' 				=> __( 'Add new entity', 'wpshop' ),
38
-				'add_new_item' 			=> __( 'Add new entity', 'wpshop' ),
39
-				'edit_item' 			=> __( 'Edit entity', 'wpshop' ),
40
-				'new_item' 				=> __( 'New entity', 'wpshop' ),
41
-				'view_item' 			=> __( 'View entity', 'wpshop' ),
42
-				'search_items' 			=> __( 'Search entities', 'wpshop' ),
43
-				'not_found' 			=> __( 'No entities found', 'wpshop' ),
44
-				'not_found_in_trash' 	=> __( 'No entities found in Trash', 'wpshop' ),
34
+				'name'					=> __('Entities', 'wpshop'),
35
+				'singular_name' 		=> __('Entity', 'wpshop'),
36
+				'add_new_item' 			=> __('Add new entity', 'wpshop'),
37
+				'add_new' 				=> __('Add new entity', 'wpshop'),
38
+				'add_new_item' 			=> __('Add new entity', 'wpshop'),
39
+				'edit_item' 			=> __('Edit entity', 'wpshop'),
40
+				'new_item' 				=> __('New entity', 'wpshop'),
41
+				'view_item' 			=> __('View entity', 'wpshop'),
42
+				'search_items' 			=> __('Search entities', 'wpshop'),
43
+				'not_found' 			=> __('No entities found', 'wpshop'),
44
+				'not_found_in_trash' 	=> __('No entities found in Trash', 'wpshop'),
45 45
 				'parent_item_colon' 	=> '',
46 46
 			),
47
-			'supports' 				=> array( 'title', 'editor', 'page-attributes' ),
47
+			'supports' 				=> array('title', 'editor', 'page-attributes'),
48 48
 			'public' 				=> true,
49 49
 			'has_archive'			=> true,
50 50
 			'publicly_queryable' 	=> false,
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 		/** Metabox allowgin to choose a custome rewrite for an entiy	*/
75 75
 		add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_rewrite', __('Rewrite for entity', 'wpshop'), array('wpshop_entities', 'wpshop_entity_rewrite'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'normal', 'high');
76 76
 
77
-		if ( !in_array( $post->post_name, unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ) ) ) {
77
+		if (!in_array($post->post_name, unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES))) {
78 78
 			/** Display or not address in admin menu	*/
79 79
 			add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_admin_menu_display', __('Display in admin menu', 'wpshop'), array('wpshop_entities', 'wpshop_display_entity_in_admin_menu'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low');
80 80
 		}
81 81
 
82 82
 		/** Join address to entity	*/
83
-		if ( !in_array( $post->post_name, array( WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) ) ) {
83
+		if (!in_array($post->post_name, array(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS))) {
84 84
 			add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_join_address_to_entity', __('Join Address to this entity', 'wpshop'), array('wpshop_entities', 'wpshop_join_address_to_entity'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low');
85 85
 		}
86 86
 	}
@@ -90,24 +90,24 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param object $post The entity type being edited
92 92
 	 */
93
-	public static function wpshop_entity_support_section( $entity ) {
93
+	public static function wpshop_entity_support_section($entity) {
94 94
 		$output = '';
95 95
 		$support_list = unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT);
96 96
 
97 97
 		$current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true);
98 98
 
99
-		unset($input_def);$input_def=array();
99
+		unset($input_def); $input_def = array();
100 100
 		$input_def['type'] = 'checkbox';
101 101
 
102
-		foreach ( $support_list as $support ) {
102
+		foreach ($support_list as $support) {
103 103
 			$input_def['id'] = 'wpshop_entity_support';
104 104
 			$input_def['name'] = $support;
105 105
 			$input_def['possible_value'] = array($support);
106
-			if ( !empty($current_entity_params['support']) && in_array($support, $current_entity_params['support']) ) {
106
+			if (!empty($current_entity_params['support']) && in_array($support, $current_entity_params['support'])) {
107 107
 				$input_def['value'] = $support;
108 108
 			}
109 109
 
110
-			$output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="'.$input_def['id'].'_'.$support.'">' . __($support, 'wpshop') . '</label></p>';
110
+			$output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="' . $input_def['id'] . '_' . $support . '">' . __($support, 'wpshop') . '</label></p>';
111 111
 		}
112 112
 		$output .= '<p class="wpshop_cls" ></p>';
113 113
 
@@ -119,32 +119,32 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param unknown_type $entity
121 121
 	 */
122
-	public static function wpshop_entity_rewrite( $entity ) {
122
+	public static function wpshop_entity_rewrite($entity) {
123 123
 		$output = '';
124 124
 
125 125
 		$current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true);
126 126
 
127
-		unset($input_def);$input_def=array();
127
+		unset($input_def); $input_def = array();
128 128
 		$input_def['type'] = 'text';
129 129
 		$input_def['id'] = 'wpshop_entity_rewrite';
130 130
 		$input_def['name'] = 'wpshop_entity_rewrite[slug]';
131
-		$input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] :'');
131
+		$input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] : '');
132 132
 
133
-		$output .= '<p><label for="'.$input_def['id'].'">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>';
133
+		$output .= '<p><label for="' . $input_def['id'] . '">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>';
134 134
 
135 135
 		echo $output;
136 136
 	}
137 137
 
138 138
 	public static function wpshop_display_entity_in_admin_menu() {
139 139
 		$checked = '';
140
-		if ( !empty($_GET['post']) ) {
140
+		if (!empty($_GET['post'])) {
141 141
 			$current_entity_params = get_post_meta(wpshop_tools::varSanitizer($_GET['post']), '_wpshop_entity_params', true);
142 142
 
143
-			if ( !empty($current_entity_params['display_admin_menu']) ) {
143
+			if (!empty($current_entity_params['display_admin_menu'])) {
144 144
 				$checked = 'checked ="checked"';
145 145
 				}
146 146
 		}
147
-		$output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' .$checked. '/><label for="wpshop_display_in_admin_menu"> '.__('Display in admin menu', 'wpshop').'</label>';
147
+		$output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' . $checked . '/><label for="wpshop_display_in_admin_menu"> ' . __('Display in admin menu', 'wpshop') . '</label>';
148 148
 		echo $output;
149 149
 	}
150 150
 
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 	 * Save custom information for entity type
153 153
 	 */
154 154
 	public static function save_entity_type_custom_informations() {
155
-		$post_id = !empty($_POST['post_ID']) ? intval( wpshop_tools::varSanitizer($_POST['post_ID']) ) : null;
155
+		$post_id = !empty($_POST['post_ID']) ? intval(wpshop_tools::varSanitizer($_POST['post_ID'])) : null;
156 156
 		$post_support = !empty($_POST['wpshop_entity_support']) ? $_POST['wpshop_entity_support'] : null;
157 157
 		$wpshop_entity_rewrite = !empty($_POST['wpshop_entity_rewrite']) ? $_POST['wpshop_entity_rewrite'] : null;
158 158
 		$wpshop_entity_display_menu = !empty($_POST['wpshop_display_in_admin_menu']) ? $_POST['wpshop_display_in_admin_menu'] : null;
159 159
 
160
-		if ( !empty ($_POST['address_type']) ) {
160
+		if (!empty ($_POST['address_type'])) {
161 161
 			$save_array = array();
162
-			foreach ( $_POST['address_type'] as $key=>$value ) {
163
-				$save_array[] = intval( wpshop_tools::varSanitizer($value) );
162
+			foreach ($_POST['address_type'] as $key=>$value) {
163
+				$save_array[] = intval(wpshop_tools::varSanitizer($value));
164 164
 			}
165
-			update_post_meta( $post_id, '_wpshop_entity_attached_address', $save_array );
165
+			update_post_meta($post_id, '_wpshop_entity_attached_address', $save_array);
166 166
 		}
167 167
 
168
-		if ( get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES ) {
168
+		if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) {
169 169
 			update_post_meta($post_id, '_wpshop_entity_params', array('support' => $post_support, 'rewrite' => $wpshop_entity_rewrite, 'display_admin_menu'=>$wpshop_entity_display_menu));
170 170
 			flush_rewrite_rules();
171 171
 		}
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
 	/**
175 175
 	 * Permite to join one or several address to an entity
176 176
 	 */
177
-	public static function wpshop_join_address_to_entity () {
177
+	public static function wpshop_join_address_to_entity() {
178 178
 		global $wpdb;
179 179
 		// Select the id of the entity address
180
-		$query = $wpdb->prepare('SELECT id FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
181
-		$entity_id = $wpdb->get_var( $query );
180
+		$query = $wpdb->prepare('SELECT id FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
181
+		$entity_id = $wpdb->get_var($query);
182 182
 		//Get the Post_meta
183
-		$attached_address_values = get_post_meta( intval(wpshop_tools::varSanitizer( (!empty($_GET['post']) ? $_GET['post'] : '') )), '_wpshop_entity_attached_address', true );
183
+		$attached_address_values = get_post_meta(intval(wpshop_tools::varSanitizer((!empty($_GET['post']) ? $_GET['post'] : ''))), '_wpshop_entity_attached_address', true);
184 184
 		//Select and Display all addresses type
185
-		$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id);
186
-		$addresses = $wpdb->get_results( $query);
185
+		$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
186
+		$addresses = $wpdb->get_results($query);
187 187
 		$output = '';
188
-		foreach ( $addresses as $address ) {
189
-			$output .= '<p><input type="checkbox" id="' .$address->name.'_'.$address->id.'" name="address_type[' .$address->name. ']" value="'.$address->id.'" ' .( ( !empty($attached_address_values) && in_array( $address->id, $attached_address_values) ) ? 'checked="checked"' : '' ). ' /> <label for="' .$address->name.'_'.$address->id.'">'.$address->name.'</label></p>';
188
+		foreach ($addresses as $address) {
189
+			$output .= '<p><input type="checkbox" id="' . $address->name . '_' . $address->id . '" name="address_type[' . $address->name . ']" value="' . $address->id . '" ' . ((!empty($attached_address_values) && in_array($address->id, $attached_address_values)) ? 'checked="checked"' : '') . ' /> <label for="' . $address->name . '_' . $address->id . '">' . $address->name . '</label></p>';
190 190
 		}
191 191
 		echo $output;
192 192
 	}
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 		/*
207 207
 		 * Read the entity list for custom type declaration
208 208
 		 */
209
-		if ( !empty($entities) ) {
210
-			foreach ( $entities as $entity ) {
211
-				$wpshop_builtin_types = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES );
212
-				if ( !empty( $entity->post_name ) && !in_array( $entity->post_name, $wpshop_builtin_types ) ) {
209
+		if (!empty($entities)) {
210
+			foreach ($entities as $entity) {
211
+				$wpshop_builtin_types = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES);
212
+				if (!empty($entity->post_name) && !in_array($entity->post_name, $wpshop_builtin_types)) {
213 213
 					$current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true);
214
-					if ( !empty($current_entity_params['display_admin_menu']) ) {
214
+					if (!empty($current_entity_params['display_admin_menu'])) {
215 215
 						$show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES;
216 216
 					}
217 217
 					else {
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 					}
220 220
 					$post_type_params = array(
221 221
 						'labels' => array(
222
-							'name'					=> __( $entity->post_title , 'wpshop' ),
223
-							'singular_name' 		=> __( $entity->post_title, 'wpshop' ),
224
-							'add_new_item' 			=> sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title),
225
-							'add_new' 				=> sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title),
226
-							'add_new_item' 			=> sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title),
227
-							'edit_item' 			=> sprintf( __( 'Edit %s', 'wpshop' ), $entity->post_title),
228
-							'new_item' 				=> sprintf( __( 'New %s', 'wpshop' ), $entity->post_title),
229
-							'view_item' 			=> sprintf( __( 'View %s', 'wpshop' ), $entity->post_title),
230
-							'search_items' 			=> sprintf( __( 'Search %s', 'wpshop' ), $entity->post_title),
231
-							'not_found' 			=> sprintf( __( 'No %s found', 'wpshop' ), $entity->post_title),
232
-							'not_found_in_trash' 	=> sprintf( __( 'No %s found in Trash', 'wpshop' ), $entity->post_title),
222
+							'name'					=> __($entity->post_title, 'wpshop'),
223
+							'singular_name' 		=> __($entity->post_title, 'wpshop'),
224
+							'add_new_item' 			=> sprintf(__('Add new %s', 'wpshop'), $entity->post_title),
225
+							'add_new' 				=> sprintf(__('Add new %s', 'wpshop'), $entity->post_title),
226
+							'add_new_item' 			=> sprintf(__('Add new %s', 'wpshop'), $entity->post_title),
227
+							'edit_item' 			=> sprintf(__('Edit %s', 'wpshop'), $entity->post_title),
228
+							'new_item' 				=> sprintf(__('New %s', 'wpshop'), $entity->post_title),
229
+							'view_item' 			=> sprintf(__('View %s', 'wpshop'), $entity->post_title),
230
+							'search_items' 			=> sprintf(__('Search %s', 'wpshop'), $entity->post_title),
231
+							'not_found' 			=> sprintf(__('No %s found', 'wpshop'), $entity->post_title),
232
+							'not_found_in_trash' 	=> sprintf(__('No %s found in Trash', 'wpshop'), $entity->post_title),
233 233
 							'parent_item_colon' 	=> '',
234 234
 						),
235 235
 						'description' 			=> $entity->post_content,
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 						'rewrite'				=> !empty($current_entity_params['rewrite']) ? $current_entity_params['rewrite'] : array(),
244 244
 						'hierarchical'			=> true,
245 245
 					);
246
-					register_post_type($entity->post_name, $post_type_params );
246
+					register_post_type($entity->post_name, $post_type_params);
247 247
 				}
248 248
 
249 249
 				/**	Add basic metabox */
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
 			}
256 256
 
257
-			add_filter( 'map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4 );
257
+			add_filter('map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4);
258 258
 			/*
259 259
 			 * Reset query for security reasons
260 260
 			 */
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 	 * @param integer $user_id
270 270
 	 * @param array $args
271 271
 	 */
272
-	public static function map_meta_cap( $caps, $cap, $user_id, $args ) {
273
-		if ( !empty($args) ) {
272
+	public static function map_meta_cap($caps, $cap, $user_id, $args) {
273
+		if (!empty($args)) {
274 274
 			$post = get_post($args[0]);
275
-			if ( false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)  || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product') ) {
275
+			if (false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product')) {
276 276
 				$caps = 'wpshop_view_dashboard';
277 277
 			}
278 278
 		}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	/**
285 285
 	 * Add metaboxes to the custom post types defined by entities
286 286
 	 */
287
-	public static function add_meta_boxes_to_custom_types( $post ) {
287
+	public static function add_meta_boxes_to_custom_types($post) {
288 288
 		global $post,
289 289
 			   $wpdb;
290 290
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		/*
300 300
 		 * Product are managed from another place
301 301
 		 */
302
-		if ( $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
302
+		if ($post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
303 303
 			/*
304 304
 			 * Get the attribute set list for current entity
305 305
 			 */
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 			 */
311 311
 			$attribute_set_id = get_post_meta($post->ID, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $post->post_type), true);
312 312
 
313
-			if(((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))){
314
-				if((count($attribute_set_list) == 1) || empty($attribute_set_id)){
313
+			if (((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))) {
314
+				if ((count($attribute_set_list) == 1) || empty($attribute_set_id)) {
315 315
 					$attribute_set_id = $attribute_set_list[0]->id;
316 316
 				}
317 317
 
@@ -324,28 +324,28 @@  discard block
 block discarded – undo
324 324
 				/*
325 325
 				 * Read the different element for building output for current entity
326 326
 				 */
327
-				if ( !empty($currentTabContent['box']) && is_array($currentTabContent['box']) ) {
327
+				if (!empty($currentTabContent['box']) && is_array($currentTabContent['box'])) {
328 328
 					foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
329
-						if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) {
329
+						if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab')) {
330 330
 							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]));
331 331
 						}
332 332
 						else $fixed_box_exist = true;
333 333
 					}
334 334
 				}
335
-				if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) {
335
+				if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
336 336
 					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 337
 				}
338 338
 			}
339 339
 			elseif (count($attribute_set_list) > 1) {
340
-				$input_def['id'] = $post->post_type.'_attribute_set_id';
341
-				$input_def['name'] = $post->post_type.'_attribute_set_id';
340
+				$input_def['id'] = $post->post_type . '_attribute_set_id';
341
+				$input_def['name'] = $post->post_type . '_attribute_set_id';
342 342
 				$input_def['value'] = '';
343 343
 				$input_def['type'] = 'select';
344 344
 				$input_def['possible_value'] = $attribute_set_list;
345 345
 
346 346
 				$input_def['value'] = '';
347 347
 				foreach ($attribute_set_list as $set) {
348
-					if( $set->default_set == 'yes' ) {
348
+					if ($set->default_set == 'yes') {
349 349
 						$input_def['value'] = $set->id;
350 350
 					}
351 351
 				}
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 				$currentTabContent = '
354 354
 		<ul class="attribute_set_selector" >
355 355
 			<li class="attribute_set_selector_title_select" ><label for="title" >' . sprintf(__('Choose a title for the %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label></li>
356
-			<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label>&nbsp;'.wpshop_form::check_input_type($input_def).'</li>
356
+			<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label>&nbsp;' . wpshop_form::check_input_type($input_def) . '</li>
357 357
 			<li class="attribute_set_selector_save_instruction" >' . sprintf(__('Save the %s with the "Save draft" button on the right side', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</li>
358 358
 			<li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li>
359 359
 		</ul>';
360 360
 
361
-				add_meta_box($post->post_type . '_attribute_set_selector',sprintf( __('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent));
361
+				add_meta_box($post->post_type . '_attribute_set_selector', sprintf(__('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent));
362 362
 			}
363 363
 
364 364
 		}
@@ -388,22 +388,22 @@  discard block
 block discarded – undo
388 388
 
389 389
 		echo '<div id="fixed-tabs" class="wpshop_tabs wpshop_detail_tabs entities_attribute_tabs ' . $post->post_type . '_attribute_tabs" >
390 390
 				<ul>';
391
-		if(!empty($currentTabContent['box'])){
392
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
393
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
394
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
395
-						echo '<li><a href="#tabs-'.$boxIdentifier.'">'.__($boxTitle, 'wpshop').'</a></li>';
391
+		if (!empty($currentTabContent['box'])) {
392
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
393
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
394
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
395
+						echo '<li><a href="#tabs-' . $boxIdentifier . '">' . __($boxTitle, 'wpshop') . '</a></li>';
396 396
 					}
397 397
 				}
398 398
 			}
399 399
 		}
400 400
 		echo '</ul>';
401 401
 
402
-		if(!empty($currentTabContent['box'])){
403
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
404
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
405
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
406
-						echo '<div id="tabs-'.$boxIdentifier.'">'.$currentTabContent['boxContent'][$boxIdentifier].'</div>';
402
+		if (!empty($currentTabContent['box'])) {
403
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
404
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
405
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
406
+						echo '<div id="tabs-' . $boxIdentifier . '">' . $currentTabContent['boxContent'][$boxIdentifier] . '</div>';
407 407
 					}
408 408
 				}
409 409
 			}
@@ -418,33 +418,33 @@  discard block
 block discarded – undo
418 418
 	/**
419 419
 	 * Save informations for current entity
420 420
 	 */
421
-	public static function save_entities_custom_informations( $post ) {
421
+	public static function save_entities_custom_informations($post) {
422 422
        global $wpdb;
423 423
        global $wpshop_account;
424
-		$post_id = !empty($_REQUEST['post_ID']) ? intval( wpshop_tools::varSanitizer($_REQUEST['post_ID']) ) : null;
424
+		$post_id = !empty($_REQUEST['post_ID']) ? intval(wpshop_tools::varSanitizer($_REQUEST['post_ID'])) : null;
425 425
 
426
-		if ( !empty($post_id) && empty($_POST['edit_other_thing']) || ( !empty($_REQUEST['post_ID']) && !(bool)$_POST['edit_other_thing'] && get_post_type($_REQUEST['post_ID']) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER  ) ) {
426
+		if (!empty($post_id) && empty($_POST['edit_other_thing']) || (!empty($_REQUEST['post_ID']) && !(bool)$_POST['edit_other_thing'] && get_post_type($_REQUEST['post_ID']) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) {
427 427
 			$current_post_type = get_post_type($post_id);
428 428
 
429 429
 
430 430
 
431 431
 
432 432
 			/*	Vérification de l'existence de l'envoi de l'identifiant du set d'attribut	*/
433
-			if	( !empty($_REQUEST[$current_post_type . '_attribute_set_id']) ) {
434
-				$attribute_set_id = intval( wpshop_tools::varSanitizer($_REQUEST[$current_post_type . '_attribute_set_id']) );
433
+			if (!empty($_REQUEST[$current_post_type . '_attribute_set_id'])) {
434
+				$attribute_set_id = intval(wpshop_tools::varSanitizer($_REQUEST[$current_post_type . '_attribute_set_id']));
435 435
 				$attribet_set_infos = wpshop_attributes_set::getElement($attribute_set_id, "'valid'", 'id');
436 436
 
437
-				if ( $attribet_set_infos->entity == $_REQUEST['post_type'] ) {
437
+				if ($attribet_set_infos->entity == $_REQUEST['post_type']) {
438 438
 					/*	Enregistrement de l'identifiant du set d'attribut associé à l'entité	*/
439 439
 					update_post_meta($post_id, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $current_post_type), $attribute_set_id);
440 440
 
441 441
 					/*	Enregistrement de tous les attributs	*/
442
-					if ( !empty($_REQUEST[$current_post_type . '_attribute']) ) {
442
+					if (!empty($_REQUEST[$current_post_type . '_attribute'])) {
443 443
 						/*	Traduction des virgule en point pour la base de donnees	*/
444
-						if ( !empty($_REQUEST[$current_post_type . '_attribute']['decimal']) ) {
445
-							foreach($_REQUEST[$current_post_type . '_attribute']['decimal'] as $attributeName => $attributeValue){
446
-								if(!is_array($attributeValue)){
447
-									$_REQUEST[$current_post_type . '_attribute']['decimal'][$attributeName] = str_replace(',','.',$_REQUEST[$current_post_type . '_attribute']['decimal'][$attributeName]);
444
+						if (!empty($_REQUEST[$current_post_type . '_attribute']['decimal'])) {
445
+							foreach ($_REQUEST[$current_post_type . '_attribute']['decimal'] as $attributeName => $attributeValue) {
446
+								if (!is_array($attributeValue)) {
447
+									$_REQUEST[$current_post_type . '_attribute']['decimal'][$attributeName] = str_replace(',', '.', $_REQUEST[$current_post_type . '_attribute']['decimal'][$attributeName]);
448 448
 								}
449 449
 							}
450 450
 						}
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 
454 454
 						/*	Enregistrement des valeurs des attributs dans les metas de l'entité => Permet de profiter de la recherche native de wordpress	*/
455 455
 						$productMetaDatas = array();
456
-						foreach ( $_REQUEST[$current_post_type . '_attribute'] as $attributeType => $attributeValues ) {
457
-							foreach ( $attributeValues as $attributeCode => $attributeValue ) {
456
+						foreach ($_REQUEST[$current_post_type . '_attribute'] as $attributeType => $attributeValues) {
457
+							foreach ($attributeValues as $attributeCode => $attributeValue) {
458 458
 								$productMetaDatas[$attributeCode] = $attributeValue;
459 459
 							}
460 460
 						}
@@ -463,42 +463,42 @@  discard block
 block discarded – undo
463 463
 					}
464 464
 				}
465 465
 			}
466
-			if ( !empty($_REQUEST['attribute']) ) {
466
+			if (!empty($_REQUEST['attribute'])) {
467 467
 				$current_id = array();
468
-				foreach ( $_REQUEST['attribute'] as $key=>$values ) {
468
+				foreach ($_REQUEST['attribute'] as $key=>$values) {
469 469
 					$ad_id = '';
470 470
 					$addresses_id = get_post_meta($_REQUEST['post_ID'], '_wpshop_attached_address', true);
471
-					if ( !empty($addresses_id) ) {
472
-						foreach ( $addresses_id as $address_id) {
471
+					if (!empty($addresses_id)) {
472
+						foreach ($addresses_id as $address_id) {
473 473
 							$address_type = get_post_meta($address_id, '_wpshop_address_attribute_set_id', true);
474 474
 							if ($address_type == $key) {
475 475
 								$ad_id = $address_id;
476 476
 							}
477 477
 						}
478 478
 					}
479
-					if( !empty( $ad_id ) ) {
479
+					if (!empty($ad_id)) {
480 480
 						$_REQUEST['item_id'] = $ad_id;
481
-						$result = wps_address::save_address_infos( $key );
481
+						$result = wps_address::save_address_infos($key);
482 482
 						$current_id[] = $result['current_id'];
483 483
 					}
484 484
 				}
485
-				if( !empty( $current_id ) ) {
486
-					update_post_meta ($_REQUEST['post_ID'], '_wpshop_attached_address', $current_id);
485
+				if (!empty($current_id)) {
486
+					update_post_meta($_REQUEST['post_ID'], '_wpshop_attached_address', $current_id);
487 487
 				}
488 488
 			}
489 489
 			else {
490 490
 				$current_id = array();
491
-				if ( !empty ($_REQUEST['address_type']) ) {
492
-					foreach ( $_REQUEST['address_type'] as $key=>$value ) {
491
+				if (!empty ($_REQUEST['address_type'])) {
492
+					foreach ($_REQUEST['address_type'] as $key=>$value) {
493 493
 						$current_id[] = $value;
494 494
 					}
495 495
 				}
496
-				update_post_meta ($_REQUEST['post_ID'], '_wpshop_entity_attached_address', $current_id);
496
+				update_post_meta($_REQUEST['post_ID'], '_wpshop_entity_attached_address', $current_id);
497 497
 			}
498 498
 		}
499 499
 
500 500
 		/** Save price infos **/
501
-		if ( !empty($_REQUEST) && !empty($_REQUEST['post_ID']) && !empty( $_REQUEST['post_type']) && $_REQUEST['post_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
501
+		if (!empty($_REQUEST) && !empty($_REQUEST['post_ID']) && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
502 502
 
503 503
 		}
504 504
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			'posts_per_page' 	=> '-1',
522 522
 		));
523 523
 
524
-		if ( !empty($entities) ) {
524
+		if (!empty($entities)) {
525 525
 			foreach ($entities as $entity_index => $entity) {
526 526
 				$entities_list[$entity->ID] = $entity->post_title;
527 527
 			}
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 		global $wpdb;
559 559
 
560 560
 		/*	Get current post information	*/
561
-		$post_infos = get_post( $post_id, ARRAY_A );
561
+		$post_infos = get_post($post_id, ARRAY_A);
562 562
 		/*	Set new information for post that will be created	*/
563 563
 		unset($post_infos['ID']);
564 564
 		$post_infos['post_date'] = current_time('mysql', 1);
@@ -576,18 +576,18 @@  discard block
 block discarded – undo
576 576
 		$last_post = wp_insert_post($post_infos);
577 577
 
578 578
 		/*	If there is no error then duplicate meta informations	*/
579
-		if ( is_int($last_post) && !empty($last_post) ) {
579
+		if (is_int($last_post) && !empty($last_post)) {
580 580
 			$meta_creation = true;
581 581
 
582 582
 			$current_post_meta = get_post_meta($post_id);
583
-			foreach ( $current_post_meta as $post_meta_key => $post_meta_value ) {
584
-				$meta_is_array = !empty( $post_meta_value[0] ) ? @unserialize($post_meta_value[0]) : '';
583
+			foreach ($current_post_meta as $post_meta_key => $post_meta_value) {
584
+				$meta_is_array = !empty($post_meta_value[0]) ? @unserialize($post_meta_value[0]) : '';
585 585
 				$meta_real_value = (is_array($meta_is_array) ? $meta_is_array : $post_meta_value[0]);
586 586
 				$meta_creation = update_post_meta($last_post, $post_meta_key, $meta_real_value);
587 587
 			}
588 588
 			/*	Duplicate element taxonomy	*/
589 589
 			/*	Check the taxonomy to get	*/
590
-			switch ( get_post_type($post_id) ) {
590
+			switch (get_post_type($post_id)) {
591 591
 				case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
592 592
 					$taxonomy = WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES;
593 593
 					break;
@@ -595,17 +595,17 @@  discard block
 block discarded – undo
595 595
 					$taxonomy = '';
596 596
 					break;
597 597
 			}
598
-			$post_taxonomies = wp_get_post_terms( $post_id,  $taxonomy);
599
-			foreach ( $post_taxonomies as $post_taxonomy ) {
600
-				wp_set_post_terms( $last_post, $post_taxonomy->term_id, $taxonomy, true);
598
+			$post_taxonomies = wp_get_post_terms($post_id, $taxonomy);
599
+			foreach ($post_taxonomies as $post_taxonomy) {
600
+				wp_set_post_terms($last_post, $post_taxonomy->term_id, $taxonomy, true);
601 601
 			}
602 602
 
603 603
 			/*	Create a post meta allowing to know if the element has been duplicated from another	*/
604 604
 			update_post_meta($last_post, '_wpshop_duplicate_element', $post_id);
605 605
 
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
-			if ( $meta_creation ) {
608
-				return array('true', '<br/>' . $new_element_link, $last_post );
607
+			if ($meta_creation) {
608
+				return array('true', '<br/>' . $new_element_link, $last_post);
609 609
 			}
610 610
 			else {
611 611
 				return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link);
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 		$query = $wpdb->prepare("SELECT code, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT WHERE status=%s AND is_used_in_admin_listing_column=%s AND entity_id=%d", 'valid', 'yes', self::get_entity_identifier_from_code($post_type));
632 632
 		$attributes_list = $wpdb->get_results($query);
633 633
 		$wpshop_custom_columns = array();
634
-		foreach ( $attributes_list as $attribute ) {
634
+		foreach ($attributes_list as $attribute) {
635 635
 			$wpshop_custom_columns[$attribute->code] = __($attribute->frontend_label, 'wpshop');
636 636
 		}
637 637
 
638 638
 		/*	Check the current entity to display custom column correctly. Add the custom column into default column list	*/
639
-		switch ( $post_type ) {
639
+		switch ($post_type) {
640 640
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
641 641
 				$columns = array_merge(array(
642 642
 					'cb' => '<input type="checkbox" />',
@@ -663,34 +663,34 @@  discard block
 block discarded – undo
663 663
 	public static function custom_columns_content($column, $post_id) {
664 664
 		$post_type = get_post_type($post_id);
665 665
 
666
-		switch ( $post_type ) {
666
+		switch ($post_type) {
667 667
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
668 668
 				$column_content = '<strong>-</strong>';
669 669
 				$product = wpshop_products::get_product_data($post_id);
670 670
 
671 671
 				switch ($column) {
672 672
 					case 'picture' :
673
-						$column_content = get_the_post_thumbnail( $post_id, 'thumbnail');
673
+						$column_content = get_the_post_thumbnail($post_id, 'thumbnail');
674 674
 					break;
675 675
 					case "product_stock":
676
-						if( !empty($product['product_stock']) )
677
-							$column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop');
676
+						if (!empty($product['product_stock']))
677
+							$column_content = (int)$product['product_stock'] . ' ' . __('unit(s)', 'wpshop');
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
 					break;
684 684
 
685 685
 					case "tx_tva":
686
-						if( !empty($product['product_price']) )
687
-							$column_content = number_format($product[$column],2,'.', ' ').' %';
686
+						if (!empty($product['product_price']))
687
+							$column_content = number_format($product[$column], 2, '.', ' ') . ' %';
688 688
 					break;
689 689
 					default:
690
-						if ( !empty($product[$column]) ) {
690
+						if (!empty($product[$column])) {
691 691
 							$attribute_prices = unserialize(WPSHOP_ATTRIBUTE_PRICES);
692
-							if ( in_array($column, $attribute_prices) ) {
693
-								$column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency();
692
+							if (in_array($column, $attribute_prices)) {
693
+								$column_content = number_format($product[$column], 2, '.', ' ') . ' ' . wpshop_tools::wpshop_get_currency();
694 694
 
695 695
 							}
696 696
 							else
@@ -711,37 +711,37 @@  discard block
 block discarded – undo
711 711
 	 * Display a form allowing to create an entity from frontend with a shortcode
712 712
 	 * @param array $shortcode_args The different parameters for the shortocde: the field list for the form, different parameters for the entity to create
713 713
 	 */
714
-	public static function wpshop_entities_shortcode( $shortcode_args ) {
714
+	public static function wpshop_entities_shortcode($shortcode_args) {
715 715
 		global $wpshop_account, $wpdb;
716 716
 		$output = $form_content = '';
717
-		if ( get_current_user_id() > 0 ) {
718
-			if ( !empty( $_POST['quick_entity_add_button'] ) ) {
717
+		if (get_current_user_id() > 0) {
718
+			if (!empty($_POST['quick_entity_add_button'])) {
719 719
 				$attributes = array();
720
-				foreach ( $_POST['attribute'] as $attribute_type => $attribute ) {
721
-					foreach ( $attribute as $attribute_code => $attribute_value ) {
720
+				foreach ($_POST['attribute'] as $attribute_type => $attribute) {
721
+					foreach ($attribute as $attribute_code => $attribute_value) {
722 722
 						$attributes[$attribute_code] = $attribute_value;
723 723
 					}
724 724
 				}
725 725
 				$result = wpshop_products::addProduct($_POST['wp_fields']['post_title'], '', $attributes, 'complete');
726 726
 			}
727 727
 
728
-			if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) {
728
+			if (empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type'])) {
729 729
 				$output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop');
730 730
 			}
731 731
 			else {
732 732
 				$entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']);
733 733
 				$attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'");
734 734
 
735
-				if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) {
735
+				if (empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id)) {
736 736
 					$output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop');
737 737
 				}
738 738
 				else {
739 739
 					/** Display wordpress fields */
740
-					foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) {
740
+					foreach (explode(', ', $shortcode_args['fields']) as $field_name) {
741 741
 						$label = '';
742
-						switch ( $field_name ) {
742
+						switch ($field_name) {
743 743
 							case 'post_title':
744
-								switch ( $shortcode_args['post_type'] ) {
744
+								switch ($shortcode_args['post_type']) {
745 745
 									case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
746 746
 										$label = __('Product title', 'wpshop');
747 747
 										break;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 								$field_type = 'text';
754 754
 							break;
755 755
 							case 'post_thumbnail':
756
-								switch ( $shortcode_args['post_type'] ) {
756
+								switch ($shortcode_args['post_type']) {
757 757
 									case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
758 758
 										$label = __('Product picture', 'wpshop');
759 759
 									break;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 							break;
767 767
 						}
768 768
 
769
-						if ( !empty( $label ) ) {
769
+						if (!empty($label)) {
770 770
 							$template_part = 'quick_entity_wp_internal_field_' . $field_type;
771 771
 							$tpl_component = array();
772 772
 							$tpl_component['WP_FIELD_NAME'] = $field_name;
@@ -799,20 +799,20 @@  discard block
 block discarded – undo
799 799
 ORDER BY ATT_GROUP.position, ATTR_DET.position"
800 800
 						, 'yes', 'valid', wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']), $shortcode_args['attribute_set_id']);
801 801
 					$attribute_for_creation = $wpdb->get_results($query);
802
-					foreach ( $attribute_for_creation as $attribute ) {
803
-						$attr_field = wpshop_attributes::display_attribute( $attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */ );
802
+					foreach ($attribute_for_creation as $attribute) {
803
+						$attr_field = wpshop_attributes::display_attribute($attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */);
804 804
 						$form_content .= $attr_field['field'];
805 805
 					}
806 806
 
807 807
 					/**	Check if there are extra parameters	*/
808
-					if ( !empty( $shortcode_args['extra_element'] ) ) {
808
+					if (!empty($shortcode_args['extra_element'])) {
809 809
 						$extra_element = explode(', ', $shortcode_args['extra_element']);
810
-						foreach ( $extra_element as $element) {
810
+						foreach ($extra_element as $element) {
811 811
 							$element_def = explode('!#wps#!', $element);
812 812
 							$element_type = $element_def[0];
813 813
 							$element_id = $element_def[1];
814 814
 
815
-							if ( $element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) {
815
+							if ($element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) {
816 816
 								$form_content .= '<div class="wpshop_entity_address_container">';
817 817
 // 								$form_content .= $wpshop_account->display_form_fields($element_id, null, 'not');
818 818
 								$form_content .= '</div><div class="wpshop_cls"></div>';
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 			$template_part = 'quick_entity_add_form';
826 826
 			$tpl_component = array();
827 827
 			$tpl_component['ENTITY_TYPE'] = $shortcode_args['post_type'];
828
-			$tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty( $shortcode_args['attribute_set_id'] ) ? $shortcode_args['attribute_set_id'] : 0;
828
+			$tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty($shortcode_args['attribute_set_id']) ? $shortcode_args['attribute_set_id'] : 0;
829 829
 			$tpl_component['NEW_ENTITY_FORM_DETAILS'] = $form_content;
830 830
 			$tpl_component['ENTITY_QUICK_ADDING_FORM_NONCE'] = wp_create_nonce("wpshop_add_new_entity_ajax_nonce");
831 831
 			$tpl_component['ENTITY_QUICK_ADD_BUTTON_TEXT'] = __($shortcode_args['button_text'], 'wpshop');
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 			$dialog_identifier = 'new_value_for_entity';
836 836
 			$dialog_input_identifier = 'wpshop_new_attribute_option_value';
837 837
 			ob_start();
838
-			include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
838
+			include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
839 839
 			$tpl_component['DIALOG_BOX'] = ob_get_contents();
840 840
 			ob_end_clean();
841 841
 			$tpl_component['DIALOG_BOX'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />';
@@ -877,14 +877,14 @@  discard block
 block discarded – undo
877 877
 		/** Add the new product	*/
878 878
 		$entity_id = wp_insert_post($entity_args);
879 879
 
880
-		do_action( 'wps_entity_more_action' , $entity_id, $attributes);
880
+		do_action('wps_entity_more_action', $entity_id, $attributes);
881 881
 
882 882
 		/** Update the attribute set id for the current product	*/
883
-		if ( !empty($extra_params['attribute_set_id']) ) {
883
+		if (!empty($extra_params['attribute_set_id'])) {
884 884
 			$attribute_set_id = $extra_params['attribute_set_id'];
885 885
 		}
886 886
 		else {
887
-			$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');
887
+			$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 888
 			$attribute_set_id = $wpdb->get_var($query);
889 889
 		}
890 890
 		update_post_meta($entity_id, '_' . $entity_type . '_attribute_set_id', $attribute_set_id);
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 	 *
903 903
 	 * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output
904 904
 	 */
905
-	public static function create_cpt_from_csv_file( $identifier, $custom_file = '' ) {
905
+	public static function create_cpt_from_csv_file($identifier, $custom_file = '') {
906 906
 		global $wpdb;
907 907
 		$output = '';
908 908
 		$container = '';
@@ -922,47 +922,47 @@  discard block
 block discarded – undo
922 922
 		$custom_post_type_identifier = $wpdb->get_var($query);
923 923
 		$container = 'wpshop_cpt_' . $identifier;
924 924
 
925
-		$file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv';
926
-		if ( is_file( $file_uri ) && empty($custom_post_type_identifier) ) {
925
+		$file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv';
926
+		if (is_file($file_uri) && empty($custom_post_type_identifier)) {
927 927
 			$csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
928 928
 
929
-			$db_field_definition = explode( ";", $csv_file_default_data[0] );
930
-			$db_datas_definition = explode( ";", $csv_file_default_data[1] );
929
+			$db_field_definition = explode(";", $csv_file_default_data[0]);
930
+			$db_datas_definition = explode(";", $csv_file_default_data[1]);
931 931
 
932 932
 			$has_error = false;
933 933
 			$errors = array();
934
-			foreach ( $custom_post_type_default_structure as $field_name => $field_default_value ) {
935
-				if ( !in_array( str_replace( 'post_', '', $field_name ) , $db_field_definition ) ) {
936
-					if ( $field_name == 'post_name' ) {
934
+			foreach ($custom_post_type_default_structure as $field_name => $field_default_value) {
935
+				if (!in_array(str_replace('post_', '', $field_name), $db_field_definition)) {
936
+					if ($field_name == 'post_name') {
937 937
 						$db_datas_definition[] = $identifier;
938
-						$db_field_definition[] = str_replace( 'post_', '', $field_name );
938
+						$db_field_definition[] = str_replace('post_', '', $field_name);
939 939
 					}
940
-					else if ( $field_default_value == 'mandatory' ) {
940
+					else if ($field_default_value == 'mandatory') {
941 941
 						$has_error = true;
942 942
 						$errors[] = $field_name;
943 943
 					}
944 944
 					else {
945 945
 						$db_datas_definition[] = $field_default_value;
946
-						$db_field_definition[] = str_replace( 'post_', '', $field_name );
946
+						$db_field_definition[] = str_replace('post_', '', $field_name);
947 947
 					}
948 948
 				}
949 949
 			}
950 950
 
951
-			if ( $has_error ) {
951
+			if ($has_error) {
952 952
 				$result = false;
953
-				$output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) );
953
+				$output = sprintf(__('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors));
954 954
 			}
955 955
 			else {
956 956
 				$custom_post_type_def = array();
957
-				foreach ( $db_field_definition as $field_position => $field_name ) {
957
+				foreach ($db_field_definition as $field_position => $field_name) {
958 958
 					$custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position];
959 959
 				}
960
-				$new_custom_post_type = wp_insert_post( $custom_post_type_def );
961
-				if ( is_int($new_custom_post_type) && !empty($new_custom_post_type) ) {
960
+				$new_custom_post_type = wp_insert_post($custom_post_type_def);
961
+				if (is_int($new_custom_post_type) && !empty($new_custom_post_type)) {
962 962
 					$result = true;
963 963
 				}
964 964
 
965
-				$check_cpt = wpshop_entities::check_default_custom_post_type( $identifier, array(), $result, $custom_file );
965
+				$check_cpt = wpshop_entities::check_default_custom_post_type($identifier, array(), $result, $custom_file);
966 966
 				$output = $check_cpt[1];
967 967
 			}
968 968
 		}
@@ -978,20 +978,20 @@  discard block
 block discarded – undo
978 978
 	 *
979 979
 	 * @return array The different response element for the request. $has_error: A boolean result of request / $output: The complete html output for custom post type check / $tpl_componene: A mode complete list of element of templates
980 980
 	 */
981
-	public static function check_default_custom_post_type( $identifier, $tpl_component ) {
981
+	public static function check_default_custom_post_type($identifier, $tpl_component) {
982 982
 		global $wpdb;
983 983
 		$has_error = false;
984 984
 
985 985
 		/**	Check if custom post type exists	*/
986 986
 		$query = $wpdb->prepare("SELECT post_title FROM " . $wpdb->posts . " WHERE post_name = %s", $identifier);
987 987
 		$custom_post_type_title = $wpdb->get_var($query);
988
-		if ( !empty($custom_post_type_title) ) {
988
+		if (!empty($custom_post_type_title)) {
989 989
 			$tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon no_error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/success_s.png" /> ' . $custom_post_type_title . ' (' . $identifier . ')';
990 990
 			$tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' no_error';
991 991
 			$tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = '';
992 992
 			$template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_no_error';
993 993
 
994
-			$attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error );
994
+			$attributes_for_cpt = wpshop_entities::check_default_cpt_attributes($identifier, $tpl_component, $has_error);
995 995
 			$has_error = $attributes_for_cpt[0];
996 996
 			$tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1];
997 997
 		}
@@ -1016,39 +1016,39 @@  discard block
 block discarded – undo
1016 1016
 	 *
1017 1017
 	 * @return array The different response element for the request. $has_error: A boolean information for request result / $output: The complete html output for attribute check
1018 1018
 	 */
1019
-	public static function check_default_cpt_attributes( $identifier, $tpl_component, $has_error, $custom_file = '' ) {
1019
+	public static function check_default_cpt_attributes($identifier, $tpl_component, $has_error, $custom_file = '') {
1020 1020
 		global $wpdb, $attribute_displayed_field;
1021 1021
 		$output = '';
1022 1022
 
1023
-		$cpt_attributes_file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv';
1024
-		if ( is_file( $cpt_attributes_file_uri ) ) {
1023
+		$cpt_attributes_file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv';
1024
+		if (is_file($cpt_attributes_file_uri)) {
1025 1025
 			/**	Read lines into file defining default datas */
1026 1026
 			$csv_file_default_data = file($cpt_attributes_file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
1027
-			if ( !empty($csv_file_default_data) ) {
1027
+			if (!empty($csv_file_default_data)) {
1028 1028
 				$header_line = explode(';', $csv_file_default_data[0]);
1029 1029
 				unset($csv_file_default_data[0]);
1030 1030
 				$code_column = null;
1031 1031
 				$available_columns = array();
1032
-				foreach ( $header_line as $column_key => $column_value ) {
1033
-					if ( $column_value == 'code' ) {
1032
+				foreach ($header_line as $column_key => $column_value) {
1033
+					if ($column_value == 'code') {
1034 1034
 						$code_column = $column_key;
1035 1035
 // 						$available_columns[$column_value] = $column_key;
1036 1036
 					}
1037
-					else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) {
1037
+					else if (in_array($column_value, array('frontend_label')/* $attribute_displayed_field */)) {
1038 1038
 						$available_columns[$column_value] = $column_key;
1039 1039
 					}
1040 1040
 				}
1041 1041
 
1042 1042
 				/**	Read the complete file content	*/
1043 1043
 				$attribute_ok = $attribute_not_ok = '  ';
1044
-				foreach ( $csv_file_default_data as $line_index => $line_content ) {
1044
+				foreach ($csv_file_default_data as $line_index => $line_content) {
1045 1045
 					$line_contents = explode(';', $line_content);
1046 1046
 					$query = $wpdb->prepare("SELECT id, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $line_contents[$code_column], wpshop_entities::get_entity_identifier_from_code($identifier));
1047
-					$attribute = $wpdb->get_row( $query );
1048
-					if ( !empty($line_contents) ) {
1049
-						foreach ( $line_contents as $line_column => $line_column_value ) {
1050
-							if ( in_array( $line_column, $available_columns ) ) {
1051
-								if ( !empty($attribute) ) {
1047
+					$attribute = $wpdb->get_row($query);
1048
+					if (!empty($line_contents)) {
1049
+						foreach ($line_contents as $line_column => $line_column_value) {
1050
+							if (in_array($line_column, $available_columns)) {
1051
+								if (!empty($attribute)) {
1052 1052
 									$attribute_ok .= $attribute->frontend_label . ', ';
1053 1053
 								}
1054 1054
 								else {
@@ -1059,18 +1059,18 @@  discard block
 block discarded – undo
1059 1059
 						}
1060 1060
 					}
1061 1061
 				}
1062
-				$attribute_not_ok = substr( $attribute_not_ok, 2, -2 );
1063
-				if ( !empty($attribute_not_ok) ) {
1064
-					$output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok )), array(), 'admin');
1062
+				$attribute_not_ok = substr($attribute_not_ok, 2, -2);
1063
+				if (!empty($attribute_not_ok)) {
1064
+					$output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok)), array(), 'admin');
1065 1065
 				}
1066
-				$attribute_ok = substr( $attribute_ok, 2, -2 );
1067
-				if ( !empty($attribute_ok) ) {
1068
-					$output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok )), array(), 'admin');
1066
+				$attribute_ok = substr($attribute_ok, 2, -2);
1067
+				if (!empty($attribute_ok)) {
1068
+					$output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok)), array(), 'admin');
1069 1069
 				}
1070 1070
 			}
1071 1071
 		}
1072 1072
 
1073
-		return array( $has_error, $output );
1073
+		return array($has_error, $output);
1074 1074
 	}
1075 1075
 
1076 1076
 	/**
@@ -1080,60 +1080,60 @@  discard block
 block discarded – undo
1080 1080
 	 *
1081 1081
 	 * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output
1082 1082
 	 */
1083
-	public static function create_cpt_attributes_from_csv_file( $identifier, $custom_file = '' ) {
1083
+	public static function create_cpt_attributes_from_csv_file($identifier, $custom_file = '') {
1084 1084
 		global $wpdb;
1085 1085
 
1086 1086
 		$output = $container = '';
1087 1087
 		$result = true;
1088 1088
 		$container = 'wpshop_cpt_' . $identifier . ' ul.wpshop_tools_default_datas_repair_attribute_container';
1089
-		$excluded_column = array( 'available_values' );
1089
+		$excluded_column = array('available_values');
1090 1090
 
1091
-		$file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv';
1092
-		if ( is_file( $file_uri ) ) {
1091
+		$file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv';
1092
+		if (is_file($file_uri)) {
1093 1093
 			$entity_id = wpshop_entities::get_entity_identifier_from_code($identifier);
1094 1094
 			$csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
1095 1095
 
1096
-			$db_field_definition = explode( ";", $csv_file_default_data[0] );
1096
+			$db_field_definition = explode(";", $csv_file_default_data[0]);
1097 1097
 			$code_column = null;
1098
-			foreach ( $db_field_definition as $column_index => $column_name ) {
1099
-				if ( $column_name == 'code' ) {
1098
+			foreach ($db_field_definition as $column_index => $column_name) {
1099
+				if ($column_name == 'code') {
1100 1100
 					$code_column = $column_index;
1101 1101
 					continue;
1102 1102
 				}
1103 1103
 			}
1104 1104
 			unset($csv_file_default_data[0]);
1105 1105
 
1106
-			if ( !empty($code_column) || ($code_column == 0) ) {
1107
-				foreach ( $csv_file_default_data as $line_index => $line_content ) {
1108
-					$attribute_definition = explode( ";", $line_content );
1109
-					$query = $wpdb->prepare( "SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id);
1106
+			if (!empty($code_column) || ($code_column == 0)) {
1107
+				foreach ($csv_file_default_data as $line_index => $line_content) {
1108
+					$attribute_definition = explode(";", $line_content);
1109
+					$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id);
1110 1110
 					$attribute_identifier = $wpdb->get_var($query);
1111 1111
 
1112
-					if ( empty($attribute_identifier) ) {
1112
+					if (empty($attribute_identifier)) {
1113 1113
 						$attribute_def = array();
1114 1114
 						$attribute_values = $default_value = null;
1115
-						foreach ( $db_field_definition as $column_index => $column_name ) {
1115
+						foreach ($db_field_definition as $column_index => $column_name) {
1116 1116
 							$column_name = trim($column_name);
1117
-							if ( !empty($column_name) && !in_array($column_name, $excluded_column) ) {
1117
+							if (!empty($column_name) && !in_array($column_name, $excluded_column)) {
1118 1118
 								$column_value = $attribute_definition[$column_index];
1119
-								switch ( $column_name ) {
1119
+								switch ($column_name) {
1120 1120
 									case 'frontend_label':
1121
-										$column_value = __( $column_value, 'wpshop' );
1121
+										$column_value = __($column_value, 'wpshop');
1122 1122
 										break;
1123 1123
 								}
1124
-								$attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : '';
1124
+								$attribute_def[$column_name] = (!empty($attribute_definition[$column_index])) ? $column_value : '';
1125 1125
 							}
1126 1126
 							else {
1127
-								switch ( $column_name ) {
1127
+								switch ($column_name) {
1128 1128
 									case 'available_values':
1129 1129
 										$attribute_values = $attribute_definition[$column_index];
1130 1130
 									break;
1131 1131
 								}
1132 1132
 							}
1133 1133
 
1134
-							switch ( $column_name ) {
1134
+							switch ($column_name) {
1135 1135
 								case 'default_value':
1136
-									$default_value = __( $attribute_definition[$column_index], 'wpshop' );
1136
+									$default_value = __($attribute_definition[$column_index], 'wpshop');
1137 1137
 								break;
1138 1138
 							}
1139 1139
 						}
@@ -1142,14 +1142,14 @@  discard block
 block discarded – undo
1142 1142
 						$last_attribute_id = $wpdb->insert_id;
1143 1143
 
1144 1144
 						/**	Create values for select element	*/
1145
-						if ( !empty($attribute_values) ) {
1146
-							$list_of_values_to_create = explode( ',', $attribute_values );
1147
-							if ( !empty($list_of_values_to_create) ) {
1148
-								foreach ( $list_of_values_to_create as $value ) {
1149
-									$value_element = explode( '!:!:!', $value);
1150
-									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __( $value_element[0], 'wpshop' ), 'value' => __( (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]) ), 'wpshop' )));
1151
-
1152
-									if ( $default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])) ) {
1145
+						if (!empty($attribute_values)) {
1146
+							$list_of_values_to_create = explode(',', $attribute_values);
1147
+							if (!empty($list_of_values_to_create)) {
1148
+								foreach ($list_of_values_to_create as $value) {
1149
+									$value_element = explode('!:!:!', $value);
1150
+									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __($value_element[0], 'wpshop'), 'value' => __((!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])), 'wpshop')));
1151
+
1152
+									if ($default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]))) {
1153 1153
 										$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $wpdb->insert_id), array('id' => $last_attribute_id, 'default_value' => $default_value));
1154 1154
 									}
1155 1155
 								}
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 			}
1162 1162
 		}
1163 1163
 
1164
-		$check_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, array(), false, $custom_file );
1164
+		$check_cpt = wpshop_entities::check_default_cpt_attributes($identifier, array(), false, $custom_file);
1165 1165
 		$output = $check_cpt[1];
1166 1166
 
1167 1167
 		return array($result, $container, $output);
Please login to merge, or discard this patch.
Braces   +31 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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];
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/myPdf.class.php 4 patches
Doc Comments   +24 added lines, -7 removed lines patch added patch discarded remove patch
@@ -131,6 +131,7 @@  discard block
 block discarded – undo
131 131
      * because it take a lot a time and a lot of memory => we use reference
132 132
      *
133 133
      * @param &HTML2PDF_myPdf object
134
+     * @param HTML2PDF_myPdf $pdf
134 135
      * @access public
135 136
      */
136 137
     public function cloneFontFrom(&$pdf)
@@ -523,8 +524,6 @@  discard block
 block discarded – undo
523 524
     /**
524 525
      * add a Translate transformation
525 526
      *
526
-     * @param float $Tx
527
-     * @param float $Ty
528 527
      * @access public
529 528
      */
530 529
     public function setTranslate($xT, $yT)
@@ -545,8 +544,6 @@  discard block
 block discarded – undo
545 544
      * add a Rotate transformation
546 545
      *
547 546
      * @param float $angle
548
-     * @param float $Cx
549
-     * @param float $Cy
550 547
      * @access public
551 548
      */
552 549
     public function setRotation($angle, $xC=null, $yC=null)
@@ -627,10 +624,18 @@  discard block
 block discarded – undo
627 624
     {
628 625
         return $this->k;
629 626
     }
627
+
628
+    /**
629
+     * @return double
630
+     */
630 631
     public function getW()
631 632
     {
632 633
         return $this->w;
633 634
     }
635
+
636
+    /**
637
+     * @return double
638
+     */
634 639
     public function getH()
635 640
     {
636 641
         return $this->h;
@@ -639,10 +644,18 @@  discard block
 block discarded – undo
639 644
     {
640 645
         return $this->lMargin;
641 646
     }
647
+
648
+    /**
649
+     * @return double
650
+     */
642 651
     public function getrMargin()
643 652
     {
644 653
         return $this->rMargin;
645 654
     }
655
+
656
+    /**
657
+     * @return double
658
+     */
646 659
     public function gettMargin()
647 660
     {
648 661
         return $this->tMargin;
@@ -969,7 +982,7 @@  discard block
 block discarded – undo
969 982
      * @param float $rx
970 983
      * @param float $ry
971 984
      * @param float $angleBegin in radians
972
-     * @param float $angleEng in radians
985
+     * @param float $angleEnd in radians
973 986
      * @param boolean $direction
974 987
      * @param boolean $drawFirst, true => add the first point
975 988
      * @param boolean $trans apply transformation
@@ -1041,8 +1054,8 @@  discard block
 block discarded – undo
1041 1054
      * @param float $rx
1042 1055
      * @param float $ry
1043 1056
      * @param float $angle deviation angle of the axis X
1044
-     * @param boolean $l large-arc-flag
1045
-     * @param boolean $s sweep-flag
1057
+     * @param integer $l large-arc-flag
1058
+     * @param integer $s sweep-flag
1046 1059
      * @param boolean $trans apply transformation
1047 1060
      * @access protected
1048 1061
      */
@@ -1142,6 +1155,8 @@  discard block
 block discarded – undo
1142 1155
      * @param float &$x
1143 1156
      * @param float &$y
1144 1157
      * @param boolean $trans true => convert into PDF unit
1158
+     * @param double $x
1159
+     * @param double $y
1145 1160
      * @return boolean
1146 1161
      * @access public
1147 1162
      */
@@ -1385,6 +1400,7 @@  discard block
 block discarded – undo
1385 1400
      *
1386 1401
      * @access public
1387 1402
      * @param integer $myLastPageGroup;
1403
+     * @param integer $myLastPageGroup
1388 1404
      */
1389 1405
     public function setMyLastPageGroup($myLastPageGroup)
1390 1406
     {
@@ -1407,6 +1423,7 @@  discard block
 block discarded – undo
1407 1423
      *
1408 1424
      * @access public
1409 1425
      * @param integer $myLastPageGroupNb;
1426
+     * @param integer $myLastPageGroupNb
1410 1427
      */
1411 1428
     public function setMyLastPageGroupNb($myLastPageGroupNb)
1412 1429
     {
Please login to merge, or discard this patch.
Indentation   +1398 added lines, -1398 removed lines patch added patch discarded remove patch
@@ -14,1402 +14,1402 @@
 block discarded – undo
14 14
 
15 15
 class HTML2PDF_myPdf extends TCPDF
16 16
 {
17
-    protected $_footerParam = array();
18
-    protected $_transf      = array();
19
-    protected $_myLastPageGroup = null;
20
-    protected $_myLastPageGroupNb = 0;
21
-
22
-    // used to make a radius with bezier : (4/3 * (sqrt(2) - 1))
23
-    const MY_ARC = 0.5522847498;
24
-
25
-    // nb of segment to build a arc with bezier curv
26
-    const ARC_NB_SEGMENT = 8;
27
-
28
-    /**
29
-     * class constructor
30
-     *
31
-     * @param string  $orientation page orientation, same as TCPDF
32
-     * @param string  $unit        User measure unit, same as TCPDF
33
-     * @param mixed   $format      The format used for pages, same as TCPDF
34
-     * @param boolean $unicode     TRUE means that the input text is unicode (default = true)
35
-     * @param String  $encoding    charset encoding; default is UTF-8
36
-     * @param boolean $diskcache   if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
37
-     * @access public
38
-     */
39
-    public function __construct(
40
-        $orientation='P',
41
-        $unit='mm',
42
-        $format='A4',
43
-        $unicode=true,
44
-        $encoding='UTF-8',
45
-        $diskcache=false)
46
-    {
47
-        // call the parent constructor
48
-        parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
49
-
50
-        // init the specific parameters used by HTML2PDF
51
-        $this->SetCreator(PDF_CREATOR);
52
-        $this->SetAutoPageBreak(false, 0);
53
-        $this->linestyleCap = '2 J';
54
-        $this->setPrintHeader(false);
55
-        $this->jpeg_quality = 90;
56
-
57
-        // prepare the automatic footer
58
-        $this->SetMyFooter();
59
-
60
-        $this->cMargin = 0;
61
-    }
62
-
63
-    /**
64
-     * Set the parameters for the automatic footer
65
-     *
66
-     * @param boolean $page display the page number
67
-     * @param boolean $date display the date
68
-     * @param boolean $hour display the hour
69
-     * @param boolean $form display a warning abour forms
70
-     * @access public
71
-     */
72
-    public function SetMyFooter($page = false, $date = false, $hour = false, $form = false)
73
-    {
74
-        $page    = ($page ? true : false);
75
-        $date    = ($date ? true : false);
76
-        $hour    = ($hour ? true : false);
77
-        $form    = ($form ? true : false);
78
-
79
-        $this->_footerParam = array('page' => $page, 'date' => $date, 'hour' => $hour, 'form' => $form);
80
-    }
81
-
82
-    /**
83
-     * This function is call automatically by TCPDF at the end of a page
84
-     * It takes no parameters
85
-     *
86
-     * @access public
87
-     */
88
-    public function Footer()
89
-    {
90
-        // prepare the text from the tranlated text
91
-        $txt = '';
92
-        if ($this->_footerParam['form']) {
93
-            $txt = (HTML2PDF_locale::get('pdf05'));
94
-        }
95
-        if ($this->_footerParam['date'] && $this->_footerParam['hour']) {
96
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf03'));
97
-        }
98
-        if ($this->_footerParam['date'] && !$this->_footerParam['hour']) {
99
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf01'));
100
-        }
101
-        if (!$this->_footerParam['date'] && $this->_footerParam['hour']) {
102
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf02'));
103
-        }
104
-        if ($this->_footerParam['page']) {
105
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf04'));
106
-        }
107
-
108
-        if (strlen($txt)>0) {
109
-            // replace some values
110
-            $toReplace = array(
111
-                '[[date_d]]'  => date('d'),
112
-                '[[date_m]]'  => date('m'),
113
-                '[[date_y]]'  => date('Y'),
114
-                '[[date_h]]'  => date('H'),
115
-                '[[date_i]]'  => date('i'),
116
-                '[[date_s]]'  => date('s'),
117
-                '[[page_cu]]' => $this->getMyNumPage(),
118
-                '[[page_nb]]' => $this->getMyAliasNbPages(),
119
-            );
120
-            $txt = str_replace(array_keys($toReplace), array_values($toReplace), $txt);
121
-
122
-            // draw the footer
123
-            parent::SetY(-11);
124
-            $this->SetFont('helvetica', 'I', 8);
125
-            $this->Cell(0, 10, $txt, 0, 0, 'R');
126
-        }
127
-    }
128
-
129
-     /**
130
-     * after cloning a object, we does not want to clone all the front informations
131
-     * because it take a lot a time and a lot of memory => we use reference
132
-     *
133
-     * @param &HTML2PDF_myPdf object
134
-     * @access public
135
-     */
136
-    public function cloneFontFrom(&$pdf)
137
-    {
138
-        $this->fonts            = &$pdf->getFonts();
139
-        $this->FontFiles        = &$pdf->getFontFiles();
140
-        $this->diffs            = &$pdf->getDiffs();
141
-        $this->fontlist         = &$pdf->getFontList();
142
-        $this->numfonts         = &$pdf->getNumFonts();
143
-        $this->fontkeys         = &$pdf->getFontKeys();
144
-        $this->font_obj_ids     = &$pdf->getFontObjIds();
145
-        $this->annotation_fonts = &$pdf->getAnnotFonts();
146
-    }
147
-
148
-    /**
149
-     * multiple public accessor for some private attributs
150
-     * used only by cloneFontFrom
151
-     *
152
-     * @return &array
153
-     * @access public
154
-     */
155
-    public function &getFonts()
156
-    {
157
-        return $this->fonts;
158
-    }
159
-    public function &getFontFiles()
160
-    {
161
-        return $this->FontFiles;
162
-    }
163
-    public function &getDiffs()
164
-    {
165
-        return $this->diffs;
166
-    }
167
-    public function &getFontList()
168
-    {
169
-        return $this->fontlist;
170
-    }
171
-    public function &getNumFonts()
172
-    {
173
-        return $this->numfonts;
174
-    }
175
-    public function &getFontKeys()
176
-    {
177
-        return $this->fontkeys;
178
-    }
179
-    public function &getFontObjIds()
180
-    {
181
-        return $this->font_obj_ids;
182
-    }
183
-    public function &getAnnotFonts()
184
-    {
185
-        return $this->annotation_fonts;
186
-    }
187
-
188
-    /**
189
-     * Verify that a Font is already loaded
190
-     *
191
-     * @param string Font Key
192
-     * @return boolean
193
-     * @access public
194
-     */
195
-    public function isLoadedFont($fontKey)
196
-    {
197
-        if (isset($this->fonts[$fontKey])) {
198
-            return true;
199
-        }
200
-
201
-        if (isset($this->CoreFonts[$fontKey])) {
202
-            return true;
203
-        }
204
-
205
-        return false;
206
-    }
207
-
208
-    /**
209
-     * Get the Word Spacing
210
-     *
211
-     * @access public
212
-     * @return float word spacing
213
-     */
214
-    public function getWordSpacing()
215
-    {
216
-        return $this->ws;
217
-    }
218
-
219
-    /**
220
-     * set the Word Spacing
221
-     *
222
-     * @param float word spacing
223
-     * @access public
224
-     */
225
-    public function setWordSpacing($ws=0.)
226
-    {
227
-        $this->ws = $ws;
228
-        $this->_out(sprintf('%.3F Tw', $ws*$this->k));
229
-    }
230
-
231
-    /**
232
-     * start to use a rectangular Cliping Path with radius corners
233
-     *
234
-     * @param float $x (top left corner)
235
-     * @param float $y (top left corner)
236
-     * @param float $w (x+w  = botom rigth corner)
237
-     * @param float $h (y+h = botom rigth corner)
238
-     * @param array $cornerTL radius of the Top Left corner
239
-     * @param array $cornerTR radius of the Top Right corner
240
-     * @param array $cornerBL radius of the Bottom Left corner
241
-     * @param array $cornerBR radius of the Bottom Right corner
242
-     * @access public
243
-     */
244
-    public function clippingPathStart(
245
-        $x = null,
246
-        $y = null,
247
-        $w = null,
248
-        $h = null,
249
-        $cornerTL=null,
250
-        $cornerTR=null,
251
-        $cornerBL=null,
252
-        $cornerBR=null)
253
-    {
254
-        // init the path
255
-        $path = '';
256
-
257
-        // if we have the position and the size of the rectangle, we can proceed
258
-        if ($x!==null && $y!==null && $w!==null && $h!==null) {
259
-            // the positions of the rectangle's corners
260
-            $x1 = $x*$this->k;
261
-            $y1 = ($this->h-$y)*$this->k;
262
-
263
-            $x2 = ($x+$w)*$this->k;
264
-            $y2 = ($this->h-$y)*$this->k;
265
-
266
-            $x3 = ($x+$w)*$this->k;
267
-            $y3 = ($this->h-$y-$h)*$this->k;
268
-
269
-            $x4 = $x*$this->k;
270
-            $y4 = ($this->h-$y-$h)*$this->k;
271
-
272
-            // if we have at least one radius corner, then we proceed to a specific path, else it is just a rectangle
273
-            if ($cornerTL || $cornerTR || $cornerBL || $cornerBR) {
274
-                // prepare the radius values
275
-                if ($cornerTL) {
276
-                    $cornerTL[0] = $cornerTL[0]*$this->k;
277
-                    $cornerTL[1] =-$cornerTL[1]*$this->k;
278
-                }
279
-                if ($cornerTR) {
280
-                    $cornerTR[0] = $cornerTR[0]*$this->k;
281
-                    $cornerTR[1] =-$cornerTR[1]*$this->k;
282
-                }
283
-                if ($cornerBL) {
284
-                    $cornerBL[0] = $cornerBL[0]*$this->k;
285
-                    $cornerBL[1] =-$cornerBL[1]*$this->k;
286
-                }
287
-                if ($cornerBR) {
288
-                    $cornerBR[0] = $cornerBR[0]*$this->k;
289
-                    $cornerBR[1] =-$cornerBR[1]*$this->k;
290
-                }
291
-
292
-                // if TL radius then specific start else (X1,Y1)
293
-                if ($cornerTL) {
294
-                    $path.= sprintf('%.2F %.2F m ', $x1+$cornerTL[0], $y1);
295
-                } else {
296
-                    $path.= sprintf('%.2F %.2F m ', $x1, $y1);
297
-                }
298
-
299
-                // if TR radius then line + arc, else line to (X2,Y2)
300
-                if ($cornerTR) {
301
-                    $xt1 = ($x2-$cornerTR[0])+$cornerTR[0]*self::MY_ARC;
302
-                    $yt1 = ($y2+$cornerTR[1])-$cornerTR[1];
303
-                    $xt2 = ($x2-$cornerTR[0])+$cornerTR[0];
304
-                    $yt2 = ($y2+$cornerTR[1])-$cornerTR[1]*self::MY_ARC;
305
-
306
-                    $path.= sprintf('%.2F %.2F l ', $x2-$cornerTR[0], $y2);
307
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2+$cornerTR[1]);
308
-                } else {
309
-                    $path.= sprintf('%.2F %.2F l ', $x2, $y2);
310
-                }
311
-
312
-                // if BR radius then line + arc, else line to (X3, Y3)
313
-                if ($cornerBR) {
314
-                    $xt1 = ($x3-$cornerBR[0])+$cornerBR[0];
315
-                    $yt1 = ($y3-$cornerBR[1])+$cornerBR[1]*self::MY_ARC;
316
-                    $xt2 = ($x3-$cornerBR[0])+$cornerBR[0]*self::MY_ARC;
317
-                    $yt2 = ($y3-$cornerBR[1])+$cornerBR[1];
318
-
319
-                    $path.= sprintf('%.2F %.2F l ', $x3, $y3-$cornerBR[1]);
320
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3-$cornerBR[0], $y3);
321
-                } else {
322
-                    $path.= sprintf('%.2F %.2F l ', $x3, $y3);
323
-                }
324
-
325
-                // if BL radius then line + arc, else line to (X4, Y4)
326
-                if ($cornerBL) {
327
-                    $xt1 = ($x4+$cornerBL[0])-$cornerBL[0]*self::MY_ARC;
328
-                    $yt1 = ($y4-$cornerBL[1])+$cornerBL[1];
329
-                    $xt2 = ($x4+$cornerBL[0])-$cornerBL[0];
330
-                    $yt2 = ($y4-$cornerBL[1])+$cornerBL[1]*self::MY_ARC;
331
-
332
-                    $path.= sprintf('%.2F %.2F l ', $x4+$cornerBL[0], $y4);
333
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4-$cornerBL[1]);
334
-                } else {
335
-                    $path.= sprintf('%.2F %.2F l ', $x4, $y4);
336
-                }
337
-
338
-                // if RL radius then line + arc
339
-                if ($cornerTL) {
340
-                    $xt1 = ($x1+$cornerTL[0])-$cornerTL[0];
341
-                    $yt1 = ($y1+$cornerTL[1])-$cornerTL[1]*self::MY_ARC;
342
-                    $xt2 = ($x1+$cornerTL[0])-$cornerTL[0]*self::MY_ARC;
343
-                    $yt2 = ($y1+$cornerTL[1])-$cornerTL[1];
344
-
345
-                    $path.= sprintf('%.2F %.2F l ', $x1, $y1+$cornerTL[1]);
346
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1+$cornerTL[0], $y1);
347
-                }
348
-            } else {
349
-                $path.= sprintf('%.2F %.2F m ', $x1, $y1);
350
-                $path.= sprintf('%.2F %.2F l ', $x2, $y2);
351
-                $path.= sprintf('%.2F %.2F l ', $x3, $y3);
352
-                $path.= sprintf('%.2F %.2F l ', $x4, $y4);
353
-            }
354
-
355
-            // close the path
356
-            $path.= ' h W n';
357
-        }
358
-
359
-        // using the path as a clipping path
360
-        $this->_out('q '.$path.' ');
361
-    }
362
-
363
-    /**
364
-     * stop to use the Cliping Path
365
-     *
366
-     * @access public
367
-     */
368
-    public function clippingPathStop()
369
-    {
370
-        $this->_out(' Q');
371
-    }
372
-
373
-    /**
374
-     * draw a filled corner of a border with a external and a internal radius
375
-     *         /--------+ ext2
376
-     *        /         |
377
-     *       /  /-------+ int2
378
-     *      /  /
379
-     *      | /
380
-     *      | |
381
-     *      | |
382
-     * ext1 +-+ int1        + cen
383
-     *
384
-     * @param float $ext1X
385
-     * @param float $ext1Y
386
-     * @param float $ext2X
387
-     * @param float $ext2Y
388
-     * @param float $int1X
389
-     * @param float $int1Y
390
-     * @param float $int2X
391
-     * @param float $int2Y
392
-     * @param float $cenX
393
-     * @param float $cenY
394
-     * @access public
395
-     */
396
-    public function drawCurve($ext1X, $ext1Y, $ext2X, $ext2Y, $int1X, $int1Y, $int2X, $int2Y, $cenX, $cenY)
397
-    {
398
-        // prepare the coordinates
399
-        $ext1X = $ext1X*$this->k;
400
-        $ext2X = $ext2X*$this->k;
401
-        $int1X = $int1X*$this->k;
402
-        $int2X = $int2X*$this->k;
403
-        $cenX  = $cenX*$this->k;
404
-
405
-        $ext1Y = ($this->h-$ext1Y)*$this->k;
406
-        $ext2Y = ($this->h-$ext2Y)*$this->k;
407
-        $int1Y = ($this->h-$int1Y)*$this->k;
408
-        $int2Y = ($this->h-$int2Y)*$this->k;
409
-        $cenY  = ($this->h-$cenY) *$this->k;
410
-
411
-        // init the curve
412
-        $path = '';
413
-
414
-        if ($ext1X-$cenX!=0) {
415
-            $xt1 = $cenX+($ext1X-$cenX);
416
-            $yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
417
-            $xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
418
-            $yt2 = $cenY+($ext2Y-$cenY);
419
-        } else {
420
-            $xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
421
-            $yt1 = $cenY+($ext1Y-$cenY);
422
-            $xt2 = $cenX+($ext2X-$cenX);
423
-            $yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
424
-        }
425
-        $path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
426
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
427
-
428
-        if ($int1X-$cenX!=0) {
429
-            $xt1 = $cenX+($int1X-$cenX)*self::MY_ARC;
430
-            $yt1 = $cenY+($int2Y-$cenY);
431
-            $xt2 = $cenX+($int1X-$cenX);
432
-            $yt2 = $cenY+($int2Y-$cenY)*self::MY_ARC;
433
-        } else {
434
-            $xt1 = $cenX+($int2X-$cenX);
435
-            $yt1 = $cenY+($int1Y-$cenY)*self::MY_ARC;
436
-            $xt2 = $cenX+($int2X-$cenX)*self::MY_ARC;
437
-            $yt2 = $cenY+($int1Y-$cenY);
438
-        }
439
-        $path.= sprintf('%.2F %.2F l ', $int2X, $int2Y);
440
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1X, $int1Y);
441
-
442
-        // draw the curve
443
-        $this->_out($path . 'f');
444
-    }
445
-
446
-    /**
447
-     * draw a filled corner of a border with only a external radius
448
-     *         /--+ ext2
449
-     *        /   |
450
-     *       /    |
451
-     *      /     |
452
-     *      |     |
453
-     *      |     |
454
-     *      |     |
455
-     * ext1 +-----+ int      + cen
456
-     *
457
-     * @param float $ext1X
458
-     * @param float $ext1Y
459
-     * @param float $ext2X
460
-     * @param float $ext2Y
461
-     * @param float $intX
462
-     * @param float $intY
463
-     * @param float $cenX
464
-     * @param float $cenY
465
-     * @access public
466
-     */
467
-    public function drawCorner($ext1X, $ext1Y, $ext2X, $ext2Y, $intX, $intY, $cenX, $cenY)
468
-    {
469
-        // prepare the coordinates
470
-        $ext1X = $ext1X*$this->k;
471
-        $ext2X = $ext2X*$this->k;
472
-        $intX  = $intX*$this->k;
473
-        $cenX  = $cenX*$this->k;
474
-
475
-        $ext1Y = ($this->h-$ext1Y)*$this->k;
476
-        $ext2Y = ($this->h-$ext2Y)*$this->k;
477
-        $intY  = ($this->h-$intY)*$this->k;
478
-        $cenY  = ($this->h-$cenY)*$this->k;
479
-
480
-        // init the curve
481
-        $path = '';
482
-
483
-        if ($ext1X-$cenX!=0) {
484
-            $xt1 = $cenX+($ext1X-$cenX);
485
-            $yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
486
-            $xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
487
-            $yt2 = $cenY+($ext2Y-$cenY);
488
-        } else {
489
-            $xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
490
-            $yt1 = $cenY+($ext1Y-$cenY);
491
-            $xt2 = $cenX+($ext2X-$cenX);
492
-            $yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
493
-        }
494
-        $path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
495
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
496
-        $path.= sprintf('%.2F %.2F l ', $intX, $intY);
497
-        $path.= sprintf('%.2F %.2F l ', $ext1X, $ext1Y);
498
-
499
-        // draw the curve
500
-        $this->_out($path . 'f');
501
-    }
502
-
503
-    /**
504
-     * Start a transformation
505
-     *
506
-     * @access public
507
-     */
508
-    public function startTransform()
509
-    {
510
-        $this->_out('q');
511
-    }
512
-
513
-    /**
514
-     * Stop a transformation
515
-     *
516
-     * @access public
517
-     */
518
-    public function stopTransform()
519
-    {
520
-        $this->_out('Q');
521
-    }
522
-
523
-    /**
524
-     * add a Translate transformation
525
-     *
526
-     * @param float $Tx
527
-     * @param float $Ty
528
-     * @access public
529
-     */
530
-    public function setTranslate($xT, $yT)
531
-    {
532
-        // Matrix for Translate
533
-        $tm[0]=1;
534
-        $tm[1]=0;
535
-        $tm[2]=0;
536
-        $tm[3]=1;
537
-        $tm[4]=$xT*$this->k;
538
-        $tm[5]=-$yT*$this->k;
539
-
540
-        // apply the Transform Matric
541
-        $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
542
-    }
543
-
544
-    /**
545
-     * add a Rotate transformation
546
-     *
547
-     * @param float $angle
548
-     * @param float $Cx
549
-     * @param float $Cy
550
-     * @access public
551
-     */
552
-    public function setRotation($angle, $xC=null, $yC=null)
553
-    {
554
-        // if no center, rotate around the current posiition
555
-        if($xC === null) $xC=$this->x;
556
-        if($yC === null) $yC=$this->y;
557
-
558
-        // prepare the coordinate
559
-        $yC=($this->h-$yC)*$this->k;
560
-        $xC*=$this->k;
561
-
562
-        // Matrix for Rotate
563
-        $tm[0]=cos(deg2rad($angle));
564
-        $tm[1]=sin(deg2rad($angle));
565
-        $tm[2]=-$tm[1];
566
-        $tm[3]=$tm[0];
567
-        $tm[4]=$xC+$tm[1]*$yC-$tm[0]*$xC;
568
-        $tm[5]=$yC-$tm[0]*$yC-$tm[1]*$xC;
569
-
570
-        // apply the Transform Matric
571
-        $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
572
-    }
573
-
574
-    /**
575
-     * we redifine the original SetX method, because we don't want the automatic treatment.
576
-     * It is HTML2PDF that make the treatment
577
-     *
578
-     * @param float   $x
579
-     * @param boolean $rtloff NOT USED
580
-     * @access public
581
-     */
582
-    public function SetX($x, $rtloff=false)
583
-    {
584
-        $this->x=$x;
585
-    }
586
-
587
-    /**
588
-     * we redifine the original SetY method, because we don't want the automatic treatment.
589
-     * It is HTML2PDF that make the treatment
590
-     *
591
-     * @param float   $y
592
-     * @param boolean $resetx Reset the X position
593
-     * @param boolean $rtloff NOT USED
594
-     * @access public
595
-     */
596
-    public function SetY($y, $resetx=true, $rtloff=false)
597
-    {
598
-        if ($resetx)
599
-            $this->x=$this->lMargin;
600
-
601
-        $this->y=$y;
602
-    }
603
-
604
-    /**
605
-     * we redifine the original SetXY method, because we don't want the automatic treatment.
606
-     * It is HTML2PDF that make the treatment
607
-     *
608
-     * @param integer $x
609
-     * @param integer $y
610
-     * @param boolean $rtloff NOT USED
611
-     * @access public
612
-     */
613
-    public function SetXY($x, $y, $rtloff=false)
614
-    {
615
-        $this->x=$x;
616
-        $this->y=$y;
617
-    }
618
-
619
-    /**
620
-     * multiple public accessor because HTML2PDF need to use TCPDF without being a extend of it
621
-     *
622
-     * @param  mixed
623
-     * @return mixed
624
-     * @access public
625
-     */
626
-    public function getK()
627
-    {
628
-        return $this->k;
629
-    }
630
-    public function getW()
631
-    {
632
-        return $this->w;
633
-    }
634
-    public function getH()
635
-    {
636
-        return $this->h;
637
-    }
638
-    public function getlMargin()
639
-    {
640
-        return $this->lMargin;
641
-    }
642
-    public function getrMargin()
643
-    {
644
-        return $this->rMargin;
645
-    }
646
-    public function gettMargin()
647
-    {
648
-        return $this->tMargin;
649
-    }
650
-    public function getbMargin()
651
-    {
652
-        return $this->bMargin;
653
-    }
654
-    public function setbMargin($v)
655
-    {
656
-        $this->bMargin=$v;
657
-    }
658
-
659
-    /**
660
-     * SVG - Convert a SVG Style in PDF Style
661
-     *
662
-     * @param  array  $styles SVG Style
663
-     * @return string PDF style
664
-     * @access public
665
-     */
666
-    public function svgSetStyle($styles)
667
-    {
668
-        // init the PDF style
669
-        $style = '';
670
-
671
-        // Style : fill
672
-        if ($styles['fill']) {
673
-            $this->setFillColorArray($styles['fill']);
674
-            $style.= 'F';
675
-        }
676
-
677
-        // Style : stroke
678
-        if ($styles['stroke'] && $styles['stroke-width']) {
679
-            $this->SetDrawColorArray($styles['stroke']);
680
-            $this->SetLineWidth($styles['stroke-width']);
681
-            $style.= 'D';
682
-        }
683
-
684
-        // Style : opacity
685
-        if ($styles['fill-opacity']) {
686
-            $this->SetAlpha($styles['fill-opacity']);
687
-        }
688
-
689
-        return $style;
690
-    }
691
-
692
-    /**
693
-     * SVG - make a Rectangle
694
-     *
695
-     * @param float $x
696
-     * @param float $y
697
-     * @param float $w
698
-     * @param float $h
699
-     * @param string $style PDF Style
700
-     * @access public
701
-     */
702
-    public function svgRect($x, $y, $w, $h, $style)
703
-    {
704
-        // prepare the 4 corners
705
-        $x1=$x;
706
-        $x2=$x+$w;
707
-        $x3=$x+$w;
708
-        $x4=$x;
709
-
710
-        $y1=$y;
711
-        $y2=$y;
712
-        $y3=$y+$h;
713
-        $y4=$y+$h;
714
-
715
-        // get the Closing operator from the PDF Style
716
-        if($style=='F') $op='f';
717
-        elseif($style=='FD' || $style=='DF') $op='B';
718
-        else $op='S';
719
-
720
-        // drawing
721
-        $this->_Point($x1, $y1, true);
722
-        $this->_Line($x2, $y2, true);
723
-        $this->_Line($x3, $y3, true);
724
-        $this->_Line($x4, $y4, true);
725
-        $this->_Line($x1, $y1, true);
726
-        $this->_out($op);
727
-    }
728
-
729
-    /**
730
-     * SVG - make a Line
731
-     *
732
-     * @param float $x1
733
-     * @param float $y1
734
-     * @param float $x2
735
-     * @param float $y2
736
-     * @access public
737
-     */
738
-    public function svgLine($x1, $y1, $x2, $y2)
739
-    {
740
-        // get the Closing operator
741
-        $op='S';
742
-
743
-        // drawing
744
-        $this->_Point($x1, $y1, true);
745
-        $this->_Line($x2, $y2, true);
746
-        $this->_out($op);
747
-    }
748
-
749
-    /**
750
-     * SVG - make a Ellipse
751
-     *
752
-     * @param float  $x0 x Center
753
-     * @param float  $y0 y Center
754
-     * @param float  $rx x radius
755
-     * @param float  $ry y radius
756
-     * @param string $style PDF Style
757
-     * @access public
758
-     */
759
-    public function svgEllipse($x0, $y0, $rx, $ry, $style)
760
-    {
761
-        // get the Closing operator from the PDF Style
762
-        if($style=='F') $op='f';
763
-        elseif($style=='FD' || $style=='DF') $op='B';
764
-        else $op='S';
765
-
766
-        // drawing
767
-        $this->_Arc($x0, $y0, $rx, $ry, 0, 2*M_PI, true, true, true);
768
-        $this->_out($op);
769
-    }
770
-
771
-    /**
772
-     * SVG - make a Advanced Polygone
773
-     *
774
-     * @param array  $actions list of actions
775
-     * @param string $style PDF Style
776
-     * @access public
777
-     */
778
-    public function svgPolygone($actions, $style)
779
-    {
780
-        // get the Closing operator from the PDF Style
781
-        if($style=='F') $op='f';
782
-        elseif($style=='FD' || $style=='DF') $op='B';
783
-        else $op='S';
784
-
785
-        // To save the First action and the last point
786
-        $first = array('', 0, 0);
787
-        $last = array(0, 0, 0, 0);
788
-
789
-        foreach ($actions as $action) {
790
-            switch($action[0])
791
-            {
792
-                // Start the Path
793
-                case 'M':
794
-                case 'm':
795
-                    $first = $action;
796
-                    $x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y;
797
-                    $this->_Point($x, $y, true);
798
-                    break;
799
-
800
-                // Close the Path
801
-                case 'Z':
802
-                case 'z':
803
-                    $x = $first[1]; $y = $first[2]; $xc = $x; $yc = $y;
804
-                    $this->_Line($x, $y, true);
805
-                    break;
806
-
807
-                // Make a Line (new point)
808
-                case 'L':
809
-                    $x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y;
810
-                    $this->_Line($x, $y, true);
811
-                    break;
812
-
813
-                // Make a Line (vector from last point)
814
-                case 'l':
815
-                    $x = $last[0]+$action[1]; $y = $last[1]+$action[2]; $xc = $x; $yc = $y;
816
-                    $this->_Line($x, $y, true);
817
-                    break;
818
-
819
-                // Make a Horizontal Line (new point)
820
-                case 'H':
821
-                    $x = $action[1]; $y = $last[1]; $xc = $x; $yc = $y;
822
-                    $this->_Line($x, $y, true);
823
-                    break;
824
-
825
-                // Make a Horisontal Line (vector from last point)
826
-                case 'h':
827
-                    $x = $last[0]+$action[1]; $y = $last[1]; $xc = $x; $yc = $y;
828
-                    $this->_Line($x, $y, true);
829
-                    break;
830
-
831
-                // Make a Vertical Line (new point)
832
-                case 'V':
833
-                    $x = $last[0]; $y = $action[1]; $xc = $x; $yc = $y;
834
-                    $this->_Line($x, $y, true);
835
-                    break;
836
-
837
-                // Make a Vertical Line (vector from last point)
838
-                case 'v':
839
-                    $x = $last[0]; $y = $last[1]+$action[1]; $xc = $x; $yc = $y;
840
-                    $this->_Line($x, $y, true);
841
-                    break;
842
-
843
-                // Make a Arc (new point)
844
-                case 'A':
845
-                    $rx = $action[1];   // rx
846
-                    $ry = $action[2];   // ry
847
-                    $a = $action[3];    // deviation angle of the axis X
848
-                    $l = $action[4];    // large-arc-flag
849
-                    $s = $action[5];    // sweep-flag
850
-                    $x1 = $last[0];     // begin x
851
-                    $y1 = $last[1];     // begin y
852
-                    $x2 = $action[6];   // final x
853
-                    $y2 = $action[7];   // final y
854
-
855
-                    $this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
856
-                    $x = $x2; $y = $y2; $xc = $x; $yc = $y;
857
-                    break;
858
-
859
-                // Make a Arc (vector from last point)
860
-                case 'a':
861
-                    $rx = $action[1];   // rx
862
-                    $ry = $action[2];   // ry
863
-                    $a = $action[3];    // deviation angle of the axis X
864
-                    $l = $action[4];    // large-arc-flag
865
-                    $s = $action[5];    // sweep-flag
866
-                    $x1 = $last[0];     // begin x
867
-                    $y1 = $last[1];     // begin y
868
-                    $x2 = $last[0]+$action[6]; // final x
869
-                    $y2 = $last[1]+$action[7]; // final y
870
-
871
-                    $this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
872
-                    $x = $x2; $y = $y2; $xc = $x; $yc = $y;
873
-                    break;
874
-
875
-                // Make a Bezier Curve (new point)
876
-                case 'C':
877
-                    $x1 = $action[1];
878
-                    $y1 = $action[2];
879
-                    $x2 = $action[3];
880
-                    $y2 = $action[4];
881
-                    $xf = $action[5];
882
-                    $yf = $action[6];
883
-                    $this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true);
884
-                    $x = $xf; $y = $yf; $xc = $x2; $yc = $y2;
885
-                    break;
886
-
887
-                // Make a Bezier Curve (vector from last point)
888
-                case 'c':
889
-                    $x1 = $last[0]+$action[1];
890
-                    $y1 = $last[1]+$action[2];
891
-                    $x2 = $last[0]+$action[3];
892
-                    $y2 = $last[1]+$action[4];
893
-                    $xf = $last[0]+$action[5];
894
-                    $yf = $last[1]+$action[6];
895
-                    $this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true);
896
-                    $x = $xf; $y = $yf; $xc = $x2; $yc = $y2;
897
-                    break;
898
-
899
-                // Unknown Path
900
-                default:
901
-                    throw new HTML2PDF_exception(0, 'SVG Path Error : ['.$action[0].'] unkown');
902
-            }
903
-
904
-            // save the last point
905
-            $last = array($x, $y, $xc, $yc);
906
-        }
907
-
908
-        // finish the path
909
-        $this->_out($op);
910
-    }
911
-
912
-    /**
913
-     * SVG - go to a point
914
-     *
915
-     * @param float   $x
916
-     * @param float   $y
917
-     * @param boolean $trans apply transformation
918
-     * @access protected
919
-     */
920
-    protected function _Point($x, $y, $trans = false)
921
-    {
922
-        if ($trans) $this->ptTransform($x, $y);
923
-
924
-        $this->_out(sprintf('%.2F %.2F m', $x, $y));
925
-    }
926
-
927
-    /**
928
-     * SVG - make a line from the last point to (x,y)
929
-     *
930
-     * @param float   $x
931
-     * @param float   $y
932
-     * @param boolean $trans apply transformation
933
-     * @access protected
934
-     */
935
-    protected function _Line($x, $y, $trans = false)
936
-    {
937
-        if ($trans) $this->ptTransform($x, $y);
938
-
939
-        $this->_out(sprintf('%.2F %.2F l', $x, $y));
940
-    }
941
-
942
-    /**
943
-     * SVG - make a bezier curve from the last point to (xf,yf), with the 2 direction points (x1,y1) and (x2,y2)
944
-     *
945
-     * @param float $x1
946
-     * @param float $y1
947
-     * @param float $x2
948
-     * @param float $y2
949
-     * @param float $xf
950
-     * @param float $yf
951
-     * @param boolean $trans apply transformation
952
-     * @access protected
953
-     */
954
-    protected function _Curve($x1, $y1, $x2, $y2, $xf, $yf, $trans = false)
955
-    {
956
-        if ($trans) {
957
-            $this->ptTransform($x1, $y1);
958
-            $this->ptTransform($x2, $y2);
959
-            $this->ptTransform($xf, $yf);
960
-        }
961
-        $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', $x1, $y1, $x2, $y2, $xf, $yf));
962
-    }
963
-
964
-    /**
965
-     * SVG - make a arc with Center, Radius, from angleBegin to angleEnd
966
-     *
967
-     * @param float $xc
968
-     * @param float $yc
969
-     * @param float $rx
970
-     * @param float $ry
971
-     * @param float $angleBegin in radians
972
-     * @param float $angleEng in radians
973
-     * @param boolean $direction
974
-     * @param boolean $drawFirst, true => add the first point
975
-     * @param boolean $trans apply transformation
976
-     * @access protected
977
-     */
978
-    protected function _Arc(
979
-        $xc,
980
-        $yc,
981
-        $rx,
982
-        $ry,
983
-        $angleBegin,
984
-        $angleEnd,
985
-        $direction = true,
986
-        $drawFirst = true,
987
-        $trans=false)
988
-    {
989
-        // if we want the no trigo direction : add 2PI to the begin angle, to invert the direction
990
-        if (!$direction) $angleBegin+= M_PI*2.;
991
-
992
-        // cut in segment to convert in berize curv
993
-        $dt = ($angleEnd - $angleBegin)/self::ARC_NB_SEGMENT;
994
-        $dtm = $dt/3;
995
-
996
-        // center of the arc
997
-        $x0 = $xc; $y0 = $yc;
998
-
999
-        // calculing the first point
1000
-        $t1 = $angleBegin;
1001
-        $a0 = $x0 + ($rx * cos($t1));
1002
-        $b0 = $y0 + ($ry * sin($t1));
1003
-        $c0 = -$rx * sin($t1);
1004
-        $d0 = $ry * cos($t1);
1005
-
1006
-        // if drawFirst => draw the first point
1007
-        if ($drawFirst) $this->_Point($a0, $b0, $trans);
1008
-
1009
-        // foreach segment
1010
-        for ($i = 1; $i <= self::ARC_NB_SEGMENT; $i++) {
1011
-            // calculing the next point
1012
-            $t1 = ($i * $dt)+$angleBegin;
1013
-            $a1 = $x0 + ($rx * cos($t1));
1014
-            $b1 = $y0 + ($ry * sin($t1));
1015
-            $c1 = -$rx * sin($t1);
1016
-            $d1 = $ry * cos($t1);
1017
-
1018
-            // make the bezier curv
1019
-            $this->_Curve(
1020
-                $a0 + ($c0 * $dtm), $b0 + ($d0 * $dtm),
1021
-                $a1 - ($c1 * $dtm), $b1 - ($d1 * $dtm),
1022
-                $a1, $b1,
1023
-                $trans
1024
-            );
1025
-
1026
-            // save the point
1027
-            $a0 = $a1;
1028
-            $b0 = $b1;
1029
-            $c0 = $c1;
1030
-            $d0 = $d1;
1031
-        }
1032
-    }
1033
-
1034
-    /**
1035
-     * SVG - make a arc from Pt1 to Pt2, with Radius
1036
-     *
1037
-     * @param float $x1
1038
-     * @param float $y1
1039
-     * @param float $x2
1040
-     * @param float $y2
1041
-     * @param float $rx
1042
-     * @param float $ry
1043
-     * @param float $angle deviation angle of the axis X
1044
-     * @param boolean $l large-arc-flag
1045
-     * @param boolean $s sweep-flag
1046
-     * @param boolean $trans apply transformation
1047
-     * @access protected
1048
-     */
1049
-    protected function _Arc2($x1, $y1, $x2, $y2, $rx, $ry, $angle=0., $l=0, $s=0, $trans = false)
1050
-    {
1051
-        // array to stock the parameters
1052
-        $v = array();
1053
-
1054
-        // the original values
1055
-        $v['x1'] = $x1;
1056
-        $v['y1'] = $y1;
1057
-        $v['x2'] = $x2;
1058
-        $v['y2'] = $y2;
1059
-        $v['rx'] = $rx;
1060
-        $v['ry'] = $ry;
1061
-
1062
-        // rotate with the deviation angle of the axis X
1063
-        $v['xr1'] = $v['x1']*cos($angle) - $v['y1']*sin($angle);
1064
-        $v['yr1'] = $v['x1']*sin($angle) + $v['y1']*cos($angle);
1065
-        $v['xr2'] = $v['x2']*cos($angle) - $v['y2']*sin($angle);
1066
-        $v['yr2'] = $v['x2']*sin($angle) + $v['y2']*cos($angle);
1067
-
1068
-        // the normalized vector
1069
-        $v['Xr1'] = $v['xr1']/$v['rx'];
1070
-        $v['Yr1'] = $v['yr1']/$v['ry'];
1071
-        $v['Xr2'] = $v['xr2']/$v['rx'];
1072
-        $v['Yr2'] = $v['yr2']/$v['ry'];
1073
-        $v['dXr'] = $v['Xr2']-$v['Xr1'];
1074
-        $v['dYr'] = $v['Yr2']-$v['Yr1'];
1075
-        $v['D'] = $v['dXr']*$v['dXr'] + $v['dYr']*$v['dYr'];
1076
-
1077
-        // if |vector| is Null, or if |vector| > 2 : impossible to make a arc => Line
1078
-        if ($v['D']==0 || $v['D']>4) {
1079
-            $this->_Line($x2, $y2, $trans);
1080
-            return false;
1081
-        }
1082
-
1083
-        // convert paramters for make a arc with Center, Radius, from angleBegin to angleEnd
1084
-        $v['s1'] = array();
1085
-        $v['s1']['t'] = sqrt((4.-$v['D'])/$v['D']);
1086
-        $v['s1']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s1']['t']*($v['Yr2']-$v['Yr1'])/2.;
1087
-        $v['s1']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s1']['t']*($v['Xr1']-$v['Xr2'])/2.;
1088
-        $v['s1']['xr'] = $v['s1']['Xr']*$v['rx'];
1089
-        $v['s1']['yr'] = $v['s1']['Yr']*$v['ry'];
1090
-        $v['s1']['x'] = $v['s1']['xr']*cos($angle)+$v['s1']['yr']*sin($angle);
1091
-        $v['s1']['y'] =-$v['s1']['xr']*sin($angle)+$v['s1']['yr']*cos($angle);
1092
-        $v['s1']['a1'] = atan2($v['y1']-$v['s1']['y'], $v['x1']-$v['s1']['x']);
1093
-        $v['s1']['a2'] = atan2($v['y2']-$v['s1']['y'], $v['x2']-$v['s1']['x']);
1094
-        if ($v['s1']['a1']>$v['s1']['a2']) $v['s1']['a1']-=2*M_PI;
1095
-
1096
-        $v['s2'] = array();
1097
-        $v['s2']['t'] = -$v['s1']['t'];
1098
-        $v['s2']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s2']['t']*($v['Yr2']-$v['Yr1'])/2.;
1099
-        $v['s2']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s2']['t']*($v['Xr1']-$v['Xr2'])/2.;
1100
-        $v['s2']['xr'] = $v['s2']['Xr']*$v['rx'];
1101
-        $v['s2']['yr'] = $v['s2']['Yr']*$v['ry'];
1102
-        $v['s2']['x'] = $v['s2']['xr']*cos($angle)+$v['s2']['yr']*sin($angle);
1103
-        $v['s2']['y'] =-$v['s2']['xr']*sin($angle)+$v['s2']['yr']*cos($angle);
1104
-        $v['s2']['a1'] = atan2($v['y1']-$v['s2']['y'], $v['x1']-$v['s2']['x']);
1105
-        $v['s2']['a2'] = atan2($v['y2']-$v['s2']['y'], $v['x2']-$v['s2']['x']);
1106
-        if ($v['s2']['a1']>$v['s2']['a2']) $v['s2']['a1']-=2*M_PI;
1107
-
1108
-        if (!$l) {
1109
-            if ($s) {
1110
-                $xc = $v['s2']['x'];
1111
-                $yc = $v['s2']['y'];
1112
-                $a1 = $v['s2']['a1'];
1113
-                $a2 = $v['s2']['a2'];
1114
-                $this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans);
1115
-            } else {
1116
-                $xc = $v['s1']['x'];
1117
-                $yc = $v['s1']['y'];
1118
-                $a1 = $v['s1']['a1'];
1119
-                $a2 = $v['s1']['a2'];
1120
-                $this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans);
1121
-            }
1122
-        } else {
1123
-            if ($s) {
1124
-                $xc = $v['s1']['x'];
1125
-                $yc = $v['s1']['y'];
1126
-                $a1 = $v['s1']['a1'];
1127
-                $a2 = $v['s1']['a2'];
1128
-                $this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans);
1129
-            } else {
1130
-                $xc = $v['s2']['x'];
1131
-                $yc = $v['s2']['y'];
1132
-                $a1 = $v['s2']['a1'];
1133
-                $a2 = $v['s2']['a2'];
1134
-                $this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans);
1135
-            }
1136
-        }
1137
-    }
1138
-
1139
-    /**
1140
-     * SVG - transform the point (reference)
1141
-     *
1142
-     * @param float &$x
1143
-     * @param float &$y
1144
-     * @param boolean $trans true => convert into PDF unit
1145
-     * @return boolean
1146
-     * @access public
1147
-     */
1148
-    public function ptTransform(&$x,  &$y, $trans=true)
1149
-    {
1150
-        // load the last Transfomation Matrix
1151
-        $nb = count($this->_transf);
1152
-        if ($nb)    $m = $this->_transf[$nb-1];
1153
-        else        $m = array(1,0,0,1,0,0);
1154
-
1155
-        // apply the Transformation Matrix
1156
-        list($x,$y) = array(($x*$m[0]+$y*$m[2]+$m[4]),($x*$m[1]+$y*$m[3]+$m[5]));
1157
-
1158
-        // if true => convert into PDF unit
1159
-        if ($trans) {
1160
-            $x = $x*$this->k;
1161
-            $y = ($this->h-$y)*$this->k;
1162
-        }
1163
-
1164
-        return true;
1165
-    }
1166
-
1167
-    /**
1168
-     * SVG - add a transformation Matric
1169
-     *
1170
-     * @param array $n matrix
1171
-     * @access public
1172
-     */
1173
-    public function doTransform($n = null)
1174
-    {
1175
-        // get the last Transformation Matrix
1176
-        $nb = count($this->_transf);
1177
-        if ($nb)    $m = $this->_transf[$nb-1];
1178
-        else        $m = array(1,0,0,1,0,0);
1179
-
1180
-        // if no transform, get the Identity Matrix
1181
-        if (!$n) $n = array(1,0,0,1,0,0);
1182
-
1183
-        // create the new Transformation Matrix
1184
-        $this->_transf[] = array(
1185
-            $m[0]*$n[0]+$m[2]*$n[1],
1186
-            $m[1]*$n[0]+$m[3]*$n[1],
1187
-            $m[0]*$n[2]+$m[2]*$n[3],
1188
-            $m[1]*$n[2]+$m[3]*$n[3],
1189
-            $m[0]*$n[4]+$m[2]*$n[5]+$m[4],
1190
-            $m[1]*$n[4]+$m[3]*$n[5]+$m[5]
1191
-        );
1192
-    }
1193
-
1194
-    /**
1195
-     * SVG - remove a transformation Matric
1196
-     *
1197
-     * @access public
1198
-     */
1199
-    public function undoTransform()
1200
-    {
1201
-        array_pop($this->_transf);
1202
-    }
1203
-
1204
-    /**
1205
-     * Convert a HTML2PDF barcode in a TCPDF barcode
1206
-     *
1207
-     * @param string $code code to print
1208
-     * @param string $type type of barcode (see tcpdf/barcodes.php for supported formats)
1209
-     * @param int $x x position in user units
1210
-     * @param int $y y position in user units
1211
-     * @param int $w width in user units
1212
-     * @param int $h height in user units
1213
-     * @param int $labelFontsize of the Test Label. If false : no Label
1214
-     * @param array $color color of the foreground
1215
-     * @access public
1216
-     */
1217
-    public function myBarcode($code, $type, $x, $y, $w, $h, $labelFontsize, $color)
1218
-    {
1219
-        // the style of the barcode
1220
-        $style = array(
1221
-            'position' => 'S',
1222
-            'text' => ($labelFontsize ? true : false),
1223
-            'fgcolor' => $color,
1224
-            'bgcolor' => false,
1225
-        );
1226
-
1227
-        // build the barcode
1228
-        $this->write1DBarcode($code, $type, $x, $y, $w, $h, '', $style, 'N');
1229
-
1230
-        // it Label => add the FontSize to the height
1231
-        if ($labelFontsize) $h+= ($labelFontsize);
1232
-
1233
-        // return the size of the barcode
1234
-        return array($w, $h);
1235
-    }
1236
-
1237
-    /**
1238
-     * create a automatic Index on a page
1239
-     *
1240
-     * @param html2pdf $obj           parent object
1241
-     * @param string   $titre         Title of the Index Page
1242
-     * @param integer  $sizeTitle     Font size for hthe Title
1243
-     * @param integer  $sizeBookmark  Font size for the bookmarks
1244
-     * @param boolean  $bookmarkTitle Bookmark the Title
1245
-     * @param boolean  $displayPage   Display the page number for each bookmark
1246
-     * @param integer  $page draw the automatic Index on a specific Page. if null => add a page at the end
1247
-     * @param string   $fontName      FontName to use
1248
-     * @access public
1249
-     */
1250
-    public function createIndex(
1251
-        &$obj,
1252
-        $titre = 'Index',
1253
-        $sizeTitle = 20,
1254
-        $sizeBookmark = 15,
1255
-        $bookmarkTitle = true,
1256
-        $displayPage = true,
1257
-        $page = null,
1258
-        $fontName = 'helvetica')
1259
-    {
1260
-        // bookmark the Title if wanted
1261
-        if ($bookmarkTitle) $this->Bookmark($titre, 0, -1);
1262
-
1263
-        // display the Title with the good Font size
1264
-        $this->SetFont($fontName, '', $sizeTitle);
1265
-        $this->Cell(0, 5, $titre, 0, 1, 'C');
1266
-
1267
-        // set the good Font size for the bookmarks
1268
-        $this->SetFont($fontName, '', $sizeBookmark);
1269
-        $this->Ln(10);
1270
-
1271
-        // get the number of bookmarks
1272
-        $size=sizeof($this->outlines);
1273
-
1274
-        // get the size of the "P. xx" cell
1275
-        $pageCellSize=$this->GetStringWidth('p. '.$this->outlines[$size-1]['p'])+2;
1276
-
1277
-        // Foreach bookmark
1278
-        for ($i=0;$i<$size;$i++) {
1279
-            // if we need a new page => add a new page
1280
-            if ($this->getY()+$this->FontSize>=($this->h - $this->bMargin)) {
1281
-                $obj->_INDEX_NewPage($page);
1282
-                $this->SetFont($fontName, '', $sizeBookmark);
1283
-            }
1284
-
1285
-            // Offset of the current level
1286
-            $level=$this->outlines[$i]['l'];
1287
-            if($level>0) $this->Cell($level*8);
1288
-
1289
-            // Caption (cut to fit on the width page)
1290
-            $str=$this->outlines[$i]['t'];
1291
-            $strsize=$this->GetStringWidth($str);
1292
-            $availableSize=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-4;
1293
-            while ($strsize>=$availableSize) {
1294
-                $str=substr($str, 0, -1);
1295
-                $strsize=$this->GetStringWidth($str);
1296
-            }
1297
-
1298
-            // if we want to display the page nmber
1299
-            if ($displayPage) {
1300
-                // display the Bookmark Caption
1301
-                $this->Cell($strsize+2, $this->FontSize+2, $str);
1302
-
1303
-                //Filling dots
1304
-                $w=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-($strsize+2);
1305
-                $nb=$w/$this->GetStringWidth('.');
1306
-                $dots=str_repeat('.', $nb);
1307
-                $this->Cell($w, $this->FontSize+2, $dots, 0, 0, 'R');
1308
-
1309
-                //Page number
1310
-                $this->Cell($pageCellSize, $this->FontSize+2, 'p. '.$this->outlines[$i]['p'], 0, 1, 'R');
1311
-            } else {
1312
-                // display the Bookmark Caption
1313
-                $this->Cell($strsize+2, $this->FontSize+2, $str, 0, 1);
1314
-            }
1315
-        }
1316
-    }
1317
-
1318
-    /**
1319
-     * Returns the string alias used for the total number of pages.
1320
-     *
1321
-     * @access public
1322
-     * @return string;
1323
-     * @see TCPDF::getAliasNbPages(), TCPDF::getPageGroupAlias()
1324
-     */
1325
-    public function getMyAliasNbPages()
1326
-    {
1327
-        if ($this->_myLastPageGroupNb==0) {
1328
-            return $this->getAliasNbPages();
1329
-        } else {
1330
-            $old = $this->currpagegroup;
1331
-            $this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
1332
-            $new = $this->getPageGroupAlias();
1333
-            $this->currpagegroup = $old;
1334
-
1335
-            return $new;
1336
-        }
1337
-    }
1338
-
1339
-    /**
1340
-     * Returns the current page number.
1341
-     *
1342
-     * @access public
1343
-     * @param  integer $page
1344
-     * @return integer;
1345
-     */
1346
-    public function getMyNumPage($page=null)
1347
-    {
1348
-        if ($page===null) {
1349
-            $page = $this->page;
1350
-        }
1351
-
1352
-        if ($this->_myLastPageGroupNb==0) {
1353
-            return $page;
1354
-        } else {
1355
-            return $page-$this->_myLastPageGroup;
1356
-        }
1357
-    }
1358
-
1359
-    /**
1360
-     * Start a new group of pages
1361
-     *
1362
-     * @access public
1363
-     * @return integer;
1364
-     * @see tcpdf::startPageGroup
1365
-     */
1366
-    public function myStartPageGroup()
1367
-    {
1368
-        $this->_myLastPageGroup = $this->page-1;
1369
-        $this->_myLastPageGroupNb++;
1370
-    }
1371
-
1372
-    /**
1373
-     * get $_myLastPageGroup;
1374
-     *
1375
-     * @access public
1376
-     * @return integer $_myLastPageGroup;
1377
-     */
1378
-    public function getMyLastPageGroup()
1379
-    {
1380
-        return $this->_myLastPageGroup;
1381
-    }
1382
-
1383
-    /**
1384
-     * set $_myLastPageGroup;
1385
-     *
1386
-     * @access public
1387
-     * @param integer $myLastPageGroup;
1388
-     */
1389
-    public function setMyLastPageGroup($myLastPageGroup)
1390
-    {
1391
-        $this->_myLastPageGroup = $myLastPageGroup;
1392
-    }
1393
-
1394
-    /**
1395
-     * get $_myLastPageGroupNb;
1396
-     *
1397
-     * @access public
1398
-     * @return integer $_myLastPageGroupNb;
1399
-     */
1400
-    public function getMyLastPageGroupNb()
1401
-    {
1402
-        return $this->_myLastPageGroupNb;
1403
-    }
1404
-
1405
-    /**
1406
-     * set $_myLastPageGroupNb;
1407
-     *
1408
-     * @access public
1409
-     * @param integer $myLastPageGroupNb;
1410
-     */
1411
-    public function setMyLastPageGroupNb($myLastPageGroupNb)
1412
-    {
1413
-        $this->_myLastPageGroupNb = $myLastPageGroupNb;
1414
-    }
17
+	protected $_footerParam = array();
18
+	protected $_transf      = array();
19
+	protected $_myLastPageGroup = null;
20
+	protected $_myLastPageGroupNb = 0;
21
+
22
+	// used to make a radius with bezier : (4/3 * (sqrt(2) - 1))
23
+	const MY_ARC = 0.5522847498;
24
+
25
+	// nb of segment to build a arc with bezier curv
26
+	const ARC_NB_SEGMENT = 8;
27
+
28
+	/**
29
+	 * class constructor
30
+	 *
31
+	 * @param string  $orientation page orientation, same as TCPDF
32
+	 * @param string  $unit        User measure unit, same as TCPDF
33
+	 * @param mixed   $format      The format used for pages, same as TCPDF
34
+	 * @param boolean $unicode     TRUE means that the input text is unicode (default = true)
35
+	 * @param String  $encoding    charset encoding; default is UTF-8
36
+	 * @param boolean $diskcache   if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
37
+	 * @access public
38
+	 */
39
+	public function __construct(
40
+		$orientation='P',
41
+		$unit='mm',
42
+		$format='A4',
43
+		$unicode=true,
44
+		$encoding='UTF-8',
45
+		$diskcache=false)
46
+	{
47
+		// call the parent constructor
48
+		parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
49
+
50
+		// init the specific parameters used by HTML2PDF
51
+		$this->SetCreator(PDF_CREATOR);
52
+		$this->SetAutoPageBreak(false, 0);
53
+		$this->linestyleCap = '2 J';
54
+		$this->setPrintHeader(false);
55
+		$this->jpeg_quality = 90;
56
+
57
+		// prepare the automatic footer
58
+		$this->SetMyFooter();
59
+
60
+		$this->cMargin = 0;
61
+	}
62
+
63
+	/**
64
+	 * Set the parameters for the automatic footer
65
+	 *
66
+	 * @param boolean $page display the page number
67
+	 * @param boolean $date display the date
68
+	 * @param boolean $hour display the hour
69
+	 * @param boolean $form display a warning abour forms
70
+	 * @access public
71
+	 */
72
+	public function SetMyFooter($page = false, $date = false, $hour = false, $form = false)
73
+	{
74
+		$page    = ($page ? true : false);
75
+		$date    = ($date ? true : false);
76
+		$hour    = ($hour ? true : false);
77
+		$form    = ($form ? true : false);
78
+
79
+		$this->_footerParam = array('page' => $page, 'date' => $date, 'hour' => $hour, 'form' => $form);
80
+	}
81
+
82
+	/**
83
+	 * This function is call automatically by TCPDF at the end of a page
84
+	 * It takes no parameters
85
+	 *
86
+	 * @access public
87
+	 */
88
+	public function Footer()
89
+	{
90
+		// prepare the text from the tranlated text
91
+		$txt = '';
92
+		if ($this->_footerParam['form']) {
93
+			$txt = (HTML2PDF_locale::get('pdf05'));
94
+		}
95
+		if ($this->_footerParam['date'] && $this->_footerParam['hour']) {
96
+			$txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf03'));
97
+		}
98
+		if ($this->_footerParam['date'] && !$this->_footerParam['hour']) {
99
+			$txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf01'));
100
+		}
101
+		if (!$this->_footerParam['date'] && $this->_footerParam['hour']) {
102
+			$txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf02'));
103
+		}
104
+		if ($this->_footerParam['page']) {
105
+			$txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf04'));
106
+		}
107
+
108
+		if (strlen($txt)>0) {
109
+			// replace some values
110
+			$toReplace = array(
111
+				'[[date_d]]'  => date('d'),
112
+				'[[date_m]]'  => date('m'),
113
+				'[[date_y]]'  => date('Y'),
114
+				'[[date_h]]'  => date('H'),
115
+				'[[date_i]]'  => date('i'),
116
+				'[[date_s]]'  => date('s'),
117
+				'[[page_cu]]' => $this->getMyNumPage(),
118
+				'[[page_nb]]' => $this->getMyAliasNbPages(),
119
+			);
120
+			$txt = str_replace(array_keys($toReplace), array_values($toReplace), $txt);
121
+
122
+			// draw the footer
123
+			parent::SetY(-11);
124
+			$this->SetFont('helvetica', 'I', 8);
125
+			$this->Cell(0, 10, $txt, 0, 0, 'R');
126
+		}
127
+	}
128
+
129
+	 /**
130
+	  * after cloning a object, we does not want to clone all the front informations
131
+	  * because it take a lot a time and a lot of memory => we use reference
132
+	  *
133
+	  * @param &HTML2PDF_myPdf object
134
+	  * @access public
135
+	  */
136
+	public function cloneFontFrom(&$pdf)
137
+	{
138
+		$this->fonts            = &$pdf->getFonts();
139
+		$this->FontFiles        = &$pdf->getFontFiles();
140
+		$this->diffs            = &$pdf->getDiffs();
141
+		$this->fontlist         = &$pdf->getFontList();
142
+		$this->numfonts         = &$pdf->getNumFonts();
143
+		$this->fontkeys         = &$pdf->getFontKeys();
144
+		$this->font_obj_ids     = &$pdf->getFontObjIds();
145
+		$this->annotation_fonts = &$pdf->getAnnotFonts();
146
+	}
147
+
148
+	/**
149
+	 * multiple public accessor for some private attributs
150
+	 * used only by cloneFontFrom
151
+	 *
152
+	 * @return &array
153
+	 * @access public
154
+	 */
155
+	public function &getFonts()
156
+	{
157
+		return $this->fonts;
158
+	}
159
+	public function &getFontFiles()
160
+	{
161
+		return $this->FontFiles;
162
+	}
163
+	public function &getDiffs()
164
+	{
165
+		return $this->diffs;
166
+	}
167
+	public function &getFontList()
168
+	{
169
+		return $this->fontlist;
170
+	}
171
+	public function &getNumFonts()
172
+	{
173
+		return $this->numfonts;
174
+	}
175
+	public function &getFontKeys()
176
+	{
177
+		return $this->fontkeys;
178
+	}
179
+	public function &getFontObjIds()
180
+	{
181
+		return $this->font_obj_ids;
182
+	}
183
+	public function &getAnnotFonts()
184
+	{
185
+		return $this->annotation_fonts;
186
+	}
187
+
188
+	/**
189
+	 * Verify that a Font is already loaded
190
+	 *
191
+	 * @param string Font Key
192
+	 * @return boolean
193
+	 * @access public
194
+	 */
195
+	public function isLoadedFont($fontKey)
196
+	{
197
+		if (isset($this->fonts[$fontKey])) {
198
+			return true;
199
+		}
200
+
201
+		if (isset($this->CoreFonts[$fontKey])) {
202
+			return true;
203
+		}
204
+
205
+		return false;
206
+	}
207
+
208
+	/**
209
+	 * Get the Word Spacing
210
+	 *
211
+	 * @access public
212
+	 * @return float word spacing
213
+	 */
214
+	public function getWordSpacing()
215
+	{
216
+		return $this->ws;
217
+	}
218
+
219
+	/**
220
+	 * set the Word Spacing
221
+	 *
222
+	 * @param float word spacing
223
+	 * @access public
224
+	 */
225
+	public function setWordSpacing($ws=0.)
226
+	{
227
+		$this->ws = $ws;
228
+		$this->_out(sprintf('%.3F Tw', $ws*$this->k));
229
+	}
230
+
231
+	/**
232
+	 * start to use a rectangular Cliping Path with radius corners
233
+	 *
234
+	 * @param float $x (top left corner)
235
+	 * @param float $y (top left corner)
236
+	 * @param float $w (x+w  = botom rigth corner)
237
+	 * @param float $h (y+h = botom rigth corner)
238
+	 * @param array $cornerTL radius of the Top Left corner
239
+	 * @param array $cornerTR radius of the Top Right corner
240
+	 * @param array $cornerBL radius of the Bottom Left corner
241
+	 * @param array $cornerBR radius of the Bottom Right corner
242
+	 * @access public
243
+	 */
244
+	public function clippingPathStart(
245
+		$x = null,
246
+		$y = null,
247
+		$w = null,
248
+		$h = null,
249
+		$cornerTL=null,
250
+		$cornerTR=null,
251
+		$cornerBL=null,
252
+		$cornerBR=null)
253
+	{
254
+		// init the path
255
+		$path = '';
256
+
257
+		// if we have the position and the size of the rectangle, we can proceed
258
+		if ($x!==null && $y!==null && $w!==null && $h!==null) {
259
+			// the positions of the rectangle's corners
260
+			$x1 = $x*$this->k;
261
+			$y1 = ($this->h-$y)*$this->k;
262
+
263
+			$x2 = ($x+$w)*$this->k;
264
+			$y2 = ($this->h-$y)*$this->k;
265
+
266
+			$x3 = ($x+$w)*$this->k;
267
+			$y3 = ($this->h-$y-$h)*$this->k;
268
+
269
+			$x4 = $x*$this->k;
270
+			$y4 = ($this->h-$y-$h)*$this->k;
271
+
272
+			// if we have at least one radius corner, then we proceed to a specific path, else it is just a rectangle
273
+			if ($cornerTL || $cornerTR || $cornerBL || $cornerBR) {
274
+				// prepare the radius values
275
+				if ($cornerTL) {
276
+					$cornerTL[0] = $cornerTL[0]*$this->k;
277
+					$cornerTL[1] =-$cornerTL[1]*$this->k;
278
+				}
279
+				if ($cornerTR) {
280
+					$cornerTR[0] = $cornerTR[0]*$this->k;
281
+					$cornerTR[1] =-$cornerTR[1]*$this->k;
282
+				}
283
+				if ($cornerBL) {
284
+					$cornerBL[0] = $cornerBL[0]*$this->k;
285
+					$cornerBL[1] =-$cornerBL[1]*$this->k;
286
+				}
287
+				if ($cornerBR) {
288
+					$cornerBR[0] = $cornerBR[0]*$this->k;
289
+					$cornerBR[1] =-$cornerBR[1]*$this->k;
290
+				}
291
+
292
+				// if TL radius then specific start else (X1,Y1)
293
+				if ($cornerTL) {
294
+					$path.= sprintf('%.2F %.2F m ', $x1+$cornerTL[0], $y1);
295
+				} else {
296
+					$path.= sprintf('%.2F %.2F m ', $x1, $y1);
297
+				}
298
+
299
+				// if TR radius then line + arc, else line to (X2,Y2)
300
+				if ($cornerTR) {
301
+					$xt1 = ($x2-$cornerTR[0])+$cornerTR[0]*self::MY_ARC;
302
+					$yt1 = ($y2+$cornerTR[1])-$cornerTR[1];
303
+					$xt2 = ($x2-$cornerTR[0])+$cornerTR[0];
304
+					$yt2 = ($y2+$cornerTR[1])-$cornerTR[1]*self::MY_ARC;
305
+
306
+					$path.= sprintf('%.2F %.2F l ', $x2-$cornerTR[0], $y2);
307
+					$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2+$cornerTR[1]);
308
+				} else {
309
+					$path.= sprintf('%.2F %.2F l ', $x2, $y2);
310
+				}
311
+
312
+				// if BR radius then line + arc, else line to (X3, Y3)
313
+				if ($cornerBR) {
314
+					$xt1 = ($x3-$cornerBR[0])+$cornerBR[0];
315
+					$yt1 = ($y3-$cornerBR[1])+$cornerBR[1]*self::MY_ARC;
316
+					$xt2 = ($x3-$cornerBR[0])+$cornerBR[0]*self::MY_ARC;
317
+					$yt2 = ($y3-$cornerBR[1])+$cornerBR[1];
318
+
319
+					$path.= sprintf('%.2F %.2F l ', $x3, $y3-$cornerBR[1]);
320
+					$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3-$cornerBR[0], $y3);
321
+				} else {
322
+					$path.= sprintf('%.2F %.2F l ', $x3, $y3);
323
+				}
324
+
325
+				// if BL radius then line + arc, else line to (X4, Y4)
326
+				if ($cornerBL) {
327
+					$xt1 = ($x4+$cornerBL[0])-$cornerBL[0]*self::MY_ARC;
328
+					$yt1 = ($y4-$cornerBL[1])+$cornerBL[1];
329
+					$xt2 = ($x4+$cornerBL[0])-$cornerBL[0];
330
+					$yt2 = ($y4-$cornerBL[1])+$cornerBL[1]*self::MY_ARC;
331
+
332
+					$path.= sprintf('%.2F %.2F l ', $x4+$cornerBL[0], $y4);
333
+					$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4-$cornerBL[1]);
334
+				} else {
335
+					$path.= sprintf('%.2F %.2F l ', $x4, $y4);
336
+				}
337
+
338
+				// if RL radius then line + arc
339
+				if ($cornerTL) {
340
+					$xt1 = ($x1+$cornerTL[0])-$cornerTL[0];
341
+					$yt1 = ($y1+$cornerTL[1])-$cornerTL[1]*self::MY_ARC;
342
+					$xt2 = ($x1+$cornerTL[0])-$cornerTL[0]*self::MY_ARC;
343
+					$yt2 = ($y1+$cornerTL[1])-$cornerTL[1];
344
+
345
+					$path.= sprintf('%.2F %.2F l ', $x1, $y1+$cornerTL[1]);
346
+					$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1+$cornerTL[0], $y1);
347
+				}
348
+			} else {
349
+				$path.= sprintf('%.2F %.2F m ', $x1, $y1);
350
+				$path.= sprintf('%.2F %.2F l ', $x2, $y2);
351
+				$path.= sprintf('%.2F %.2F l ', $x3, $y3);
352
+				$path.= sprintf('%.2F %.2F l ', $x4, $y4);
353
+			}
354
+
355
+			// close the path
356
+			$path.= ' h W n';
357
+		}
358
+
359
+		// using the path as a clipping path
360
+		$this->_out('q '.$path.' ');
361
+	}
362
+
363
+	/**
364
+	 * stop to use the Cliping Path
365
+	 *
366
+	 * @access public
367
+	 */
368
+	public function clippingPathStop()
369
+	{
370
+		$this->_out(' Q');
371
+	}
372
+
373
+	/**
374
+	 * draw a filled corner of a border with a external and a internal radius
375
+	 *         /--------+ ext2
376
+	 *        /         |
377
+	 *       /  /-------+ int2
378
+	 *      /  /
379
+	 *      | /
380
+	 *      | |
381
+	 *      | |
382
+	 * ext1 +-+ int1        + cen
383
+	 *
384
+	 * @param float $ext1X
385
+	 * @param float $ext1Y
386
+	 * @param float $ext2X
387
+	 * @param float $ext2Y
388
+	 * @param float $int1X
389
+	 * @param float $int1Y
390
+	 * @param float $int2X
391
+	 * @param float $int2Y
392
+	 * @param float $cenX
393
+	 * @param float $cenY
394
+	 * @access public
395
+	 */
396
+	public function drawCurve($ext1X, $ext1Y, $ext2X, $ext2Y, $int1X, $int1Y, $int2X, $int2Y, $cenX, $cenY)
397
+	{
398
+		// prepare the coordinates
399
+		$ext1X = $ext1X*$this->k;
400
+		$ext2X = $ext2X*$this->k;
401
+		$int1X = $int1X*$this->k;
402
+		$int2X = $int2X*$this->k;
403
+		$cenX  = $cenX*$this->k;
404
+
405
+		$ext1Y = ($this->h-$ext1Y)*$this->k;
406
+		$ext2Y = ($this->h-$ext2Y)*$this->k;
407
+		$int1Y = ($this->h-$int1Y)*$this->k;
408
+		$int2Y = ($this->h-$int2Y)*$this->k;
409
+		$cenY  = ($this->h-$cenY) *$this->k;
410
+
411
+		// init the curve
412
+		$path = '';
413
+
414
+		if ($ext1X-$cenX!=0) {
415
+			$xt1 = $cenX+($ext1X-$cenX);
416
+			$yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
417
+			$xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
418
+			$yt2 = $cenY+($ext2Y-$cenY);
419
+		} else {
420
+			$xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
421
+			$yt1 = $cenY+($ext1Y-$cenY);
422
+			$xt2 = $cenX+($ext2X-$cenX);
423
+			$yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
424
+		}
425
+		$path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
426
+		$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
427
+
428
+		if ($int1X-$cenX!=0) {
429
+			$xt1 = $cenX+($int1X-$cenX)*self::MY_ARC;
430
+			$yt1 = $cenY+($int2Y-$cenY);
431
+			$xt2 = $cenX+($int1X-$cenX);
432
+			$yt2 = $cenY+($int2Y-$cenY)*self::MY_ARC;
433
+		} else {
434
+			$xt1 = $cenX+($int2X-$cenX);
435
+			$yt1 = $cenY+($int1Y-$cenY)*self::MY_ARC;
436
+			$xt2 = $cenX+($int2X-$cenX)*self::MY_ARC;
437
+			$yt2 = $cenY+($int1Y-$cenY);
438
+		}
439
+		$path.= sprintf('%.2F %.2F l ', $int2X, $int2Y);
440
+		$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1X, $int1Y);
441
+
442
+		// draw the curve
443
+		$this->_out($path . 'f');
444
+	}
445
+
446
+	/**
447
+	 * draw a filled corner of a border with only a external radius
448
+	 *         /--+ ext2
449
+	 *        /   |
450
+	 *       /    |
451
+	 *      /     |
452
+	 *      |     |
453
+	 *      |     |
454
+	 *      |     |
455
+	 * ext1 +-----+ int      + cen
456
+	 *
457
+	 * @param float $ext1X
458
+	 * @param float $ext1Y
459
+	 * @param float $ext2X
460
+	 * @param float $ext2Y
461
+	 * @param float $intX
462
+	 * @param float $intY
463
+	 * @param float $cenX
464
+	 * @param float $cenY
465
+	 * @access public
466
+	 */
467
+	public function drawCorner($ext1X, $ext1Y, $ext2X, $ext2Y, $intX, $intY, $cenX, $cenY)
468
+	{
469
+		// prepare the coordinates
470
+		$ext1X = $ext1X*$this->k;
471
+		$ext2X = $ext2X*$this->k;
472
+		$intX  = $intX*$this->k;
473
+		$cenX  = $cenX*$this->k;
474
+
475
+		$ext1Y = ($this->h-$ext1Y)*$this->k;
476
+		$ext2Y = ($this->h-$ext2Y)*$this->k;
477
+		$intY  = ($this->h-$intY)*$this->k;
478
+		$cenY  = ($this->h-$cenY)*$this->k;
479
+
480
+		// init the curve
481
+		$path = '';
482
+
483
+		if ($ext1X-$cenX!=0) {
484
+			$xt1 = $cenX+($ext1X-$cenX);
485
+			$yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
486
+			$xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
487
+			$yt2 = $cenY+($ext2Y-$cenY);
488
+		} else {
489
+			$xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
490
+			$yt1 = $cenY+($ext1Y-$cenY);
491
+			$xt2 = $cenX+($ext2X-$cenX);
492
+			$yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
493
+		}
494
+		$path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
495
+		$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
496
+		$path.= sprintf('%.2F %.2F l ', $intX, $intY);
497
+		$path.= sprintf('%.2F %.2F l ', $ext1X, $ext1Y);
498
+
499
+		// draw the curve
500
+		$this->_out($path . 'f');
501
+	}
502
+
503
+	/**
504
+	 * Start a transformation
505
+	 *
506
+	 * @access public
507
+	 */
508
+	public function startTransform()
509
+	{
510
+		$this->_out('q');
511
+	}
512
+
513
+	/**
514
+	 * Stop a transformation
515
+	 *
516
+	 * @access public
517
+	 */
518
+	public function stopTransform()
519
+	{
520
+		$this->_out('Q');
521
+	}
522
+
523
+	/**
524
+	 * add a Translate transformation
525
+	 *
526
+	 * @param float $Tx
527
+	 * @param float $Ty
528
+	 * @access public
529
+	 */
530
+	public function setTranslate($xT, $yT)
531
+	{
532
+		// Matrix for Translate
533
+		$tm[0]=1;
534
+		$tm[1]=0;
535
+		$tm[2]=0;
536
+		$tm[3]=1;
537
+		$tm[4]=$xT*$this->k;
538
+		$tm[5]=-$yT*$this->k;
539
+
540
+		// apply the Transform Matric
541
+		$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
542
+	}
543
+
544
+	/**
545
+	 * add a Rotate transformation
546
+	 *
547
+	 * @param float $angle
548
+	 * @param float $Cx
549
+	 * @param float $Cy
550
+	 * @access public
551
+	 */
552
+	public function setRotation($angle, $xC=null, $yC=null)
553
+	{
554
+		// if no center, rotate around the current posiition
555
+		if($xC === null) $xC=$this->x;
556
+		if($yC === null) $yC=$this->y;
557
+
558
+		// prepare the coordinate
559
+		$yC=($this->h-$yC)*$this->k;
560
+		$xC*=$this->k;
561
+
562
+		// Matrix for Rotate
563
+		$tm[0]=cos(deg2rad($angle));
564
+		$tm[1]=sin(deg2rad($angle));
565
+		$tm[2]=-$tm[1];
566
+		$tm[3]=$tm[0];
567
+		$tm[4]=$xC+$tm[1]*$yC-$tm[0]*$xC;
568
+		$tm[5]=$yC-$tm[0]*$yC-$tm[1]*$xC;
569
+
570
+		// apply the Transform Matric
571
+		$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
572
+	}
573
+
574
+	/**
575
+	 * we redifine the original SetX method, because we don't want the automatic treatment.
576
+	 * It is HTML2PDF that make the treatment
577
+	 *
578
+	 * @param float   $x
579
+	 * @param boolean $rtloff NOT USED
580
+	 * @access public
581
+	 */
582
+	public function SetX($x, $rtloff=false)
583
+	{
584
+		$this->x=$x;
585
+	}
586
+
587
+	/**
588
+	 * we redifine the original SetY method, because we don't want the automatic treatment.
589
+	 * It is HTML2PDF that make the treatment
590
+	 *
591
+	 * @param float   $y
592
+	 * @param boolean $resetx Reset the X position
593
+	 * @param boolean $rtloff NOT USED
594
+	 * @access public
595
+	 */
596
+	public function SetY($y, $resetx=true, $rtloff=false)
597
+	{
598
+		if ($resetx)
599
+			$this->x=$this->lMargin;
600
+
601
+		$this->y=$y;
602
+	}
603
+
604
+	/**
605
+	 * we redifine the original SetXY method, because we don't want the automatic treatment.
606
+	 * It is HTML2PDF that make the treatment
607
+	 *
608
+	 * @param integer $x
609
+	 * @param integer $y
610
+	 * @param boolean $rtloff NOT USED
611
+	 * @access public
612
+	 */
613
+	public function SetXY($x, $y, $rtloff=false)
614
+	{
615
+		$this->x=$x;
616
+		$this->y=$y;
617
+	}
618
+
619
+	/**
620
+	 * multiple public accessor because HTML2PDF need to use TCPDF without being a extend of it
621
+	 *
622
+	 * @param  mixed
623
+	 * @return mixed
624
+	 * @access public
625
+	 */
626
+	public function getK()
627
+	{
628
+		return $this->k;
629
+	}
630
+	public function getW()
631
+	{
632
+		return $this->w;
633
+	}
634
+	public function getH()
635
+	{
636
+		return $this->h;
637
+	}
638
+	public function getlMargin()
639
+	{
640
+		return $this->lMargin;
641
+	}
642
+	public function getrMargin()
643
+	{
644
+		return $this->rMargin;
645
+	}
646
+	public function gettMargin()
647
+	{
648
+		return $this->tMargin;
649
+	}
650
+	public function getbMargin()
651
+	{
652
+		return $this->bMargin;
653
+	}
654
+	public function setbMargin($v)
655
+	{
656
+		$this->bMargin=$v;
657
+	}
658
+
659
+	/**
660
+	 * SVG - Convert a SVG Style in PDF Style
661
+	 *
662
+	 * @param  array  $styles SVG Style
663
+	 * @return string PDF style
664
+	 * @access public
665
+	 */
666
+	public function svgSetStyle($styles)
667
+	{
668
+		// init the PDF style
669
+		$style = '';
670
+
671
+		// Style : fill
672
+		if ($styles['fill']) {
673
+			$this->setFillColorArray($styles['fill']);
674
+			$style.= 'F';
675
+		}
676
+
677
+		// Style : stroke
678
+		if ($styles['stroke'] && $styles['stroke-width']) {
679
+			$this->SetDrawColorArray($styles['stroke']);
680
+			$this->SetLineWidth($styles['stroke-width']);
681
+			$style.= 'D';
682
+		}
683
+
684
+		// Style : opacity
685
+		if ($styles['fill-opacity']) {
686
+			$this->SetAlpha($styles['fill-opacity']);
687
+		}
688
+
689
+		return $style;
690
+	}
691
+
692
+	/**
693
+	 * SVG - make a Rectangle
694
+	 *
695
+	 * @param float $x
696
+	 * @param float $y
697
+	 * @param float $w
698
+	 * @param float $h
699
+	 * @param string $style PDF Style
700
+	 * @access public
701
+	 */
702
+	public function svgRect($x, $y, $w, $h, $style)
703
+	{
704
+		// prepare the 4 corners
705
+		$x1=$x;
706
+		$x2=$x+$w;
707
+		$x3=$x+$w;
708
+		$x4=$x;
709
+
710
+		$y1=$y;
711
+		$y2=$y;
712
+		$y3=$y+$h;
713
+		$y4=$y+$h;
714
+
715
+		// get the Closing operator from the PDF Style
716
+		if($style=='F') $op='f';
717
+		elseif($style=='FD' || $style=='DF') $op='B';
718
+		else $op='S';
719
+
720
+		// drawing
721
+		$this->_Point($x1, $y1, true);
722
+		$this->_Line($x2, $y2, true);
723
+		$this->_Line($x3, $y3, true);
724
+		$this->_Line($x4, $y4, true);
725
+		$this->_Line($x1, $y1, true);
726
+		$this->_out($op);
727
+	}
728
+
729
+	/**
730
+	 * SVG - make a Line
731
+	 *
732
+	 * @param float $x1
733
+	 * @param float $y1
734
+	 * @param float $x2
735
+	 * @param float $y2
736
+	 * @access public
737
+	 */
738
+	public function svgLine($x1, $y1, $x2, $y2)
739
+	{
740
+		// get the Closing operator
741
+		$op='S';
742
+
743
+		// drawing
744
+		$this->_Point($x1, $y1, true);
745
+		$this->_Line($x2, $y2, true);
746
+		$this->_out($op);
747
+	}
748
+
749
+	/**
750
+	 * SVG - make a Ellipse
751
+	 *
752
+	 * @param float  $x0 x Center
753
+	 * @param float  $y0 y Center
754
+	 * @param float  $rx x radius
755
+	 * @param float  $ry y radius
756
+	 * @param string $style PDF Style
757
+	 * @access public
758
+	 */
759
+	public function svgEllipse($x0, $y0, $rx, $ry, $style)
760
+	{
761
+		// get the Closing operator from the PDF Style
762
+		if($style=='F') $op='f';
763
+		elseif($style=='FD' || $style=='DF') $op='B';
764
+		else $op='S';
765
+
766
+		// drawing
767
+		$this->_Arc($x0, $y0, $rx, $ry, 0, 2*M_PI, true, true, true);
768
+		$this->_out($op);
769
+	}
770
+
771
+	/**
772
+	 * SVG - make a Advanced Polygone
773
+	 *
774
+	 * @param array  $actions list of actions
775
+	 * @param string $style PDF Style
776
+	 * @access public
777
+	 */
778
+	public function svgPolygone($actions, $style)
779
+	{
780
+		// get the Closing operator from the PDF Style
781
+		if($style=='F') $op='f';
782
+		elseif($style=='FD' || $style=='DF') $op='B';
783
+		else $op='S';
784
+
785
+		// To save the First action and the last point
786
+		$first = array('', 0, 0);
787
+		$last = array(0, 0, 0, 0);
788
+
789
+		foreach ($actions as $action) {
790
+			switch($action[0])
791
+			{
792
+				// Start the Path
793
+				case 'M':
794
+				case 'm':
795
+					$first = $action;
796
+					$x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y;
797
+					$this->_Point($x, $y, true);
798
+					break;
799
+
800
+				// Close the Path
801
+				case 'Z':
802
+				case 'z':
803
+					$x = $first[1]; $y = $first[2]; $xc = $x; $yc = $y;
804
+					$this->_Line($x, $y, true);
805
+					break;
806
+
807
+				// Make a Line (new point)
808
+				case 'L':
809
+					$x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y;
810
+					$this->_Line($x, $y, true);
811
+					break;
812
+
813
+				// Make a Line (vector from last point)
814
+				case 'l':
815
+					$x = $last[0]+$action[1]; $y = $last[1]+$action[2]; $xc = $x; $yc = $y;
816
+					$this->_Line($x, $y, true);
817
+					break;
818
+
819
+				// Make a Horizontal Line (new point)
820
+				case 'H':
821
+					$x = $action[1]; $y = $last[1]; $xc = $x; $yc = $y;
822
+					$this->_Line($x, $y, true);
823
+					break;
824
+
825
+				// Make a Horisontal Line (vector from last point)
826
+				case 'h':
827
+					$x = $last[0]+$action[1]; $y = $last[1]; $xc = $x; $yc = $y;
828
+					$this->_Line($x, $y, true);
829
+					break;
830
+
831
+				// Make a Vertical Line (new point)
832
+				case 'V':
833
+					$x = $last[0]; $y = $action[1]; $xc = $x; $yc = $y;
834
+					$this->_Line($x, $y, true);
835
+					break;
836
+
837
+				// Make a Vertical Line (vector from last point)
838
+				case 'v':
839
+					$x = $last[0]; $y = $last[1]+$action[1]; $xc = $x; $yc = $y;
840
+					$this->_Line($x, $y, true);
841
+					break;
842
+
843
+				// Make a Arc (new point)
844
+				case 'A':
845
+					$rx = $action[1];   // rx
846
+					$ry = $action[2];   // ry
847
+					$a = $action[3];    // deviation angle of the axis X
848
+					$l = $action[4];    // large-arc-flag
849
+					$s = $action[5];    // sweep-flag
850
+					$x1 = $last[0];     // begin x
851
+					$y1 = $last[1];     // begin y
852
+					$x2 = $action[6];   // final x
853
+					$y2 = $action[7];   // final y
854
+
855
+					$this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
856
+					$x = $x2; $y = $y2; $xc = $x; $yc = $y;
857
+					break;
858
+
859
+				// Make a Arc (vector from last point)
860
+				case 'a':
861
+					$rx = $action[1];   // rx
862
+					$ry = $action[2];   // ry
863
+					$a = $action[3];    // deviation angle of the axis X
864
+					$l = $action[4];    // large-arc-flag
865
+					$s = $action[5];    // sweep-flag
866
+					$x1 = $last[0];     // begin x
867
+					$y1 = $last[1];     // begin y
868
+					$x2 = $last[0]+$action[6]; // final x
869
+					$y2 = $last[1]+$action[7]; // final y
870
+
871
+					$this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
872
+					$x = $x2; $y = $y2; $xc = $x; $yc = $y;
873
+					break;
874
+
875
+				// Make a Bezier Curve (new point)
876
+				case 'C':
877
+					$x1 = $action[1];
878
+					$y1 = $action[2];
879
+					$x2 = $action[3];
880
+					$y2 = $action[4];
881
+					$xf = $action[5];
882
+					$yf = $action[6];
883
+					$this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true);
884
+					$x = $xf; $y = $yf; $xc = $x2; $yc = $y2;
885
+					break;
886
+
887
+				// Make a Bezier Curve (vector from last point)
888
+				case 'c':
889
+					$x1 = $last[0]+$action[1];
890
+					$y1 = $last[1]+$action[2];
891
+					$x2 = $last[0]+$action[3];
892
+					$y2 = $last[1]+$action[4];
893
+					$xf = $last[0]+$action[5];
894
+					$yf = $last[1]+$action[6];
895
+					$this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true);
896
+					$x = $xf; $y = $yf; $xc = $x2; $yc = $y2;
897
+					break;
898
+
899
+				// Unknown Path
900
+				default:
901
+					throw new HTML2PDF_exception(0, 'SVG Path Error : ['.$action[0].'] unkown');
902
+			}
903
+
904
+			// save the last point
905
+			$last = array($x, $y, $xc, $yc);
906
+		}
907
+
908
+		// finish the path
909
+		$this->_out($op);
910
+	}
911
+
912
+	/**
913
+	 * SVG - go to a point
914
+	 *
915
+	 * @param float   $x
916
+	 * @param float   $y
917
+	 * @param boolean $trans apply transformation
918
+	 * @access protected
919
+	 */
920
+	protected function _Point($x, $y, $trans = false)
921
+	{
922
+		if ($trans) $this->ptTransform($x, $y);
923
+
924
+		$this->_out(sprintf('%.2F %.2F m', $x, $y));
925
+	}
926
+
927
+	/**
928
+	 * SVG - make a line from the last point to (x,y)
929
+	 *
930
+	 * @param float   $x
931
+	 * @param float   $y
932
+	 * @param boolean $trans apply transformation
933
+	 * @access protected
934
+	 */
935
+	protected function _Line($x, $y, $trans = false)
936
+	{
937
+		if ($trans) $this->ptTransform($x, $y);
938
+
939
+		$this->_out(sprintf('%.2F %.2F l', $x, $y));
940
+	}
941
+
942
+	/**
943
+	 * SVG - make a bezier curve from the last point to (xf,yf), with the 2 direction points (x1,y1) and (x2,y2)
944
+	 *
945
+	 * @param float $x1
946
+	 * @param float $y1
947
+	 * @param float $x2
948
+	 * @param float $y2
949
+	 * @param float $xf
950
+	 * @param float $yf
951
+	 * @param boolean $trans apply transformation
952
+	 * @access protected
953
+	 */
954
+	protected function _Curve($x1, $y1, $x2, $y2, $xf, $yf, $trans = false)
955
+	{
956
+		if ($trans) {
957
+			$this->ptTransform($x1, $y1);
958
+			$this->ptTransform($x2, $y2);
959
+			$this->ptTransform($xf, $yf);
960
+		}
961
+		$this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', $x1, $y1, $x2, $y2, $xf, $yf));
962
+	}
963
+
964
+	/**
965
+	 * SVG - make a arc with Center, Radius, from angleBegin to angleEnd
966
+	 *
967
+	 * @param float $xc
968
+	 * @param float $yc
969
+	 * @param float $rx
970
+	 * @param float $ry
971
+	 * @param float $angleBegin in radians
972
+	 * @param float $angleEng in radians
973
+	 * @param boolean $direction
974
+	 * @param boolean $drawFirst, true => add the first point
975
+	 * @param boolean $trans apply transformation
976
+	 * @access protected
977
+	 */
978
+	protected function _Arc(
979
+		$xc,
980
+		$yc,
981
+		$rx,
982
+		$ry,
983
+		$angleBegin,
984
+		$angleEnd,
985
+		$direction = true,
986
+		$drawFirst = true,
987
+		$trans=false)
988
+	{
989
+		// if we want the no trigo direction : add 2PI to the begin angle, to invert the direction
990
+		if (!$direction) $angleBegin+= M_PI*2.;
991
+
992
+		// cut in segment to convert in berize curv
993
+		$dt = ($angleEnd - $angleBegin)/self::ARC_NB_SEGMENT;
994
+		$dtm = $dt/3;
995
+
996
+		// center of the arc
997
+		$x0 = $xc; $y0 = $yc;
998
+
999
+		// calculing the first point
1000
+		$t1 = $angleBegin;
1001
+		$a0 = $x0 + ($rx * cos($t1));
1002
+		$b0 = $y0 + ($ry * sin($t1));
1003
+		$c0 = -$rx * sin($t1);
1004
+		$d0 = $ry * cos($t1);
1005
+
1006
+		// if drawFirst => draw the first point
1007
+		if ($drawFirst) $this->_Point($a0, $b0, $trans);
1008
+
1009
+		// foreach segment
1010
+		for ($i = 1; $i <= self::ARC_NB_SEGMENT; $i++) {
1011
+			// calculing the next point
1012
+			$t1 = ($i * $dt)+$angleBegin;
1013
+			$a1 = $x0 + ($rx * cos($t1));
1014
+			$b1 = $y0 + ($ry * sin($t1));
1015
+			$c1 = -$rx * sin($t1);
1016
+			$d1 = $ry * cos($t1);
1017
+
1018
+			// make the bezier curv
1019
+			$this->_Curve(
1020
+				$a0 + ($c0 * $dtm), $b0 + ($d0 * $dtm),
1021
+				$a1 - ($c1 * $dtm), $b1 - ($d1 * $dtm),
1022
+				$a1, $b1,
1023
+				$trans
1024
+			);
1025
+
1026
+			// save the point
1027
+			$a0 = $a1;
1028
+			$b0 = $b1;
1029
+			$c0 = $c1;
1030
+			$d0 = $d1;
1031
+		}
1032
+	}
1033
+
1034
+	/**
1035
+	 * SVG - make a arc from Pt1 to Pt2, with Radius
1036
+	 *
1037
+	 * @param float $x1
1038
+	 * @param float $y1
1039
+	 * @param float $x2
1040
+	 * @param float $y2
1041
+	 * @param float $rx
1042
+	 * @param float $ry
1043
+	 * @param float $angle deviation angle of the axis X
1044
+	 * @param boolean $l large-arc-flag
1045
+	 * @param boolean $s sweep-flag
1046
+	 * @param boolean $trans apply transformation
1047
+	 * @access protected
1048
+	 */
1049
+	protected function _Arc2($x1, $y1, $x2, $y2, $rx, $ry, $angle=0., $l=0, $s=0, $trans = false)
1050
+	{
1051
+		// array to stock the parameters
1052
+		$v = array();
1053
+
1054
+		// the original values
1055
+		$v['x1'] = $x1;
1056
+		$v['y1'] = $y1;
1057
+		$v['x2'] = $x2;
1058
+		$v['y2'] = $y2;
1059
+		$v['rx'] = $rx;
1060
+		$v['ry'] = $ry;
1061
+
1062
+		// rotate with the deviation angle of the axis X
1063
+		$v['xr1'] = $v['x1']*cos($angle) - $v['y1']*sin($angle);
1064
+		$v['yr1'] = $v['x1']*sin($angle) + $v['y1']*cos($angle);
1065
+		$v['xr2'] = $v['x2']*cos($angle) - $v['y2']*sin($angle);
1066
+		$v['yr2'] = $v['x2']*sin($angle) + $v['y2']*cos($angle);
1067
+
1068
+		// the normalized vector
1069
+		$v['Xr1'] = $v['xr1']/$v['rx'];
1070
+		$v['Yr1'] = $v['yr1']/$v['ry'];
1071
+		$v['Xr2'] = $v['xr2']/$v['rx'];
1072
+		$v['Yr2'] = $v['yr2']/$v['ry'];
1073
+		$v['dXr'] = $v['Xr2']-$v['Xr1'];
1074
+		$v['dYr'] = $v['Yr2']-$v['Yr1'];
1075
+		$v['D'] = $v['dXr']*$v['dXr'] + $v['dYr']*$v['dYr'];
1076
+
1077
+		// if |vector| is Null, or if |vector| > 2 : impossible to make a arc => Line
1078
+		if ($v['D']==0 || $v['D']>4) {
1079
+			$this->_Line($x2, $y2, $trans);
1080
+			return false;
1081
+		}
1082
+
1083
+		// convert paramters for make a arc with Center, Radius, from angleBegin to angleEnd
1084
+		$v['s1'] = array();
1085
+		$v['s1']['t'] = sqrt((4.-$v['D'])/$v['D']);
1086
+		$v['s1']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s1']['t']*($v['Yr2']-$v['Yr1'])/2.;
1087
+		$v['s1']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s1']['t']*($v['Xr1']-$v['Xr2'])/2.;
1088
+		$v['s1']['xr'] = $v['s1']['Xr']*$v['rx'];
1089
+		$v['s1']['yr'] = $v['s1']['Yr']*$v['ry'];
1090
+		$v['s1']['x'] = $v['s1']['xr']*cos($angle)+$v['s1']['yr']*sin($angle);
1091
+		$v['s1']['y'] =-$v['s1']['xr']*sin($angle)+$v['s1']['yr']*cos($angle);
1092
+		$v['s1']['a1'] = atan2($v['y1']-$v['s1']['y'], $v['x1']-$v['s1']['x']);
1093
+		$v['s1']['a2'] = atan2($v['y2']-$v['s1']['y'], $v['x2']-$v['s1']['x']);
1094
+		if ($v['s1']['a1']>$v['s1']['a2']) $v['s1']['a1']-=2*M_PI;
1095
+
1096
+		$v['s2'] = array();
1097
+		$v['s2']['t'] = -$v['s1']['t'];
1098
+		$v['s2']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s2']['t']*($v['Yr2']-$v['Yr1'])/2.;
1099
+		$v['s2']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s2']['t']*($v['Xr1']-$v['Xr2'])/2.;
1100
+		$v['s2']['xr'] = $v['s2']['Xr']*$v['rx'];
1101
+		$v['s2']['yr'] = $v['s2']['Yr']*$v['ry'];
1102
+		$v['s2']['x'] = $v['s2']['xr']*cos($angle)+$v['s2']['yr']*sin($angle);
1103
+		$v['s2']['y'] =-$v['s2']['xr']*sin($angle)+$v['s2']['yr']*cos($angle);
1104
+		$v['s2']['a1'] = atan2($v['y1']-$v['s2']['y'], $v['x1']-$v['s2']['x']);
1105
+		$v['s2']['a2'] = atan2($v['y2']-$v['s2']['y'], $v['x2']-$v['s2']['x']);
1106
+		if ($v['s2']['a1']>$v['s2']['a2']) $v['s2']['a1']-=2*M_PI;
1107
+
1108
+		if (!$l) {
1109
+			if ($s) {
1110
+				$xc = $v['s2']['x'];
1111
+				$yc = $v['s2']['y'];
1112
+				$a1 = $v['s2']['a1'];
1113
+				$a2 = $v['s2']['a2'];
1114
+				$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans);
1115
+			} else {
1116
+				$xc = $v['s1']['x'];
1117
+				$yc = $v['s1']['y'];
1118
+				$a1 = $v['s1']['a1'];
1119
+				$a2 = $v['s1']['a2'];
1120
+				$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans);
1121
+			}
1122
+		} else {
1123
+			if ($s) {
1124
+				$xc = $v['s1']['x'];
1125
+				$yc = $v['s1']['y'];
1126
+				$a1 = $v['s1']['a1'];
1127
+				$a2 = $v['s1']['a2'];
1128
+				$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans);
1129
+			} else {
1130
+				$xc = $v['s2']['x'];
1131
+				$yc = $v['s2']['y'];
1132
+				$a1 = $v['s2']['a1'];
1133
+				$a2 = $v['s2']['a2'];
1134
+				$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans);
1135
+			}
1136
+		}
1137
+	}
1138
+
1139
+	/**
1140
+	 * SVG - transform the point (reference)
1141
+	 *
1142
+	 * @param float &$x
1143
+	 * @param float &$y
1144
+	 * @param boolean $trans true => convert into PDF unit
1145
+	 * @return boolean
1146
+	 * @access public
1147
+	 */
1148
+	public function ptTransform(&$x,  &$y, $trans=true)
1149
+	{
1150
+		// load the last Transfomation Matrix
1151
+		$nb = count($this->_transf);
1152
+		if ($nb)    $m = $this->_transf[$nb-1];
1153
+		else        $m = array(1,0,0,1,0,0);
1154
+
1155
+		// apply the Transformation Matrix
1156
+		list($x,$y) = array(($x*$m[0]+$y*$m[2]+$m[4]),($x*$m[1]+$y*$m[3]+$m[5]));
1157
+
1158
+		// if true => convert into PDF unit
1159
+		if ($trans) {
1160
+			$x = $x*$this->k;
1161
+			$y = ($this->h-$y)*$this->k;
1162
+		}
1163
+
1164
+		return true;
1165
+	}
1166
+
1167
+	/**
1168
+	 * SVG - add a transformation Matric
1169
+	 *
1170
+	 * @param array $n matrix
1171
+	 * @access public
1172
+	 */
1173
+	public function doTransform($n = null)
1174
+	{
1175
+		// get the last Transformation Matrix
1176
+		$nb = count($this->_transf);
1177
+		if ($nb)    $m = $this->_transf[$nb-1];
1178
+		else        $m = array(1,0,0,1,0,0);
1179
+
1180
+		// if no transform, get the Identity Matrix
1181
+		if (!$n) $n = array(1,0,0,1,0,0);
1182
+
1183
+		// create the new Transformation Matrix
1184
+		$this->_transf[] = array(
1185
+			$m[0]*$n[0]+$m[2]*$n[1],
1186
+			$m[1]*$n[0]+$m[3]*$n[1],
1187
+			$m[0]*$n[2]+$m[2]*$n[3],
1188
+			$m[1]*$n[2]+$m[3]*$n[3],
1189
+			$m[0]*$n[4]+$m[2]*$n[5]+$m[4],
1190
+			$m[1]*$n[4]+$m[3]*$n[5]+$m[5]
1191
+		);
1192
+	}
1193
+
1194
+	/**
1195
+	 * SVG - remove a transformation Matric
1196
+	 *
1197
+	 * @access public
1198
+	 */
1199
+	public function undoTransform()
1200
+	{
1201
+		array_pop($this->_transf);
1202
+	}
1203
+
1204
+	/**
1205
+	 * Convert a HTML2PDF barcode in a TCPDF barcode
1206
+	 *
1207
+	 * @param string $code code to print
1208
+	 * @param string $type type of barcode (see tcpdf/barcodes.php for supported formats)
1209
+	 * @param int $x x position in user units
1210
+	 * @param int $y y position in user units
1211
+	 * @param int $w width in user units
1212
+	 * @param int $h height in user units
1213
+	 * @param int $labelFontsize of the Test Label. If false : no Label
1214
+	 * @param array $color color of the foreground
1215
+	 * @access public
1216
+	 */
1217
+	public function myBarcode($code, $type, $x, $y, $w, $h, $labelFontsize, $color)
1218
+	{
1219
+		// the style of the barcode
1220
+		$style = array(
1221
+			'position' => 'S',
1222
+			'text' => ($labelFontsize ? true : false),
1223
+			'fgcolor' => $color,
1224
+			'bgcolor' => false,
1225
+		);
1226
+
1227
+		// build the barcode
1228
+		$this->write1DBarcode($code, $type, $x, $y, $w, $h, '', $style, 'N');
1229
+
1230
+		// it Label => add the FontSize to the height
1231
+		if ($labelFontsize) $h+= ($labelFontsize);
1232
+
1233
+		// return the size of the barcode
1234
+		return array($w, $h);
1235
+	}
1236
+
1237
+	/**
1238
+	 * create a automatic Index on a page
1239
+	 *
1240
+	 * @param html2pdf $obj           parent object
1241
+	 * @param string   $titre         Title of the Index Page
1242
+	 * @param integer  $sizeTitle     Font size for hthe Title
1243
+	 * @param integer  $sizeBookmark  Font size for the bookmarks
1244
+	 * @param boolean  $bookmarkTitle Bookmark the Title
1245
+	 * @param boolean  $displayPage   Display the page number for each bookmark
1246
+	 * @param integer  $page draw the automatic Index on a specific Page. if null => add a page at the end
1247
+	 * @param string   $fontName      FontName to use
1248
+	 * @access public
1249
+	 */
1250
+	public function createIndex(
1251
+		&$obj,
1252
+		$titre = 'Index',
1253
+		$sizeTitle = 20,
1254
+		$sizeBookmark = 15,
1255
+		$bookmarkTitle = true,
1256
+		$displayPage = true,
1257
+		$page = null,
1258
+		$fontName = 'helvetica')
1259
+	{
1260
+		// bookmark the Title if wanted
1261
+		if ($bookmarkTitle) $this->Bookmark($titre, 0, -1);
1262
+
1263
+		// display the Title with the good Font size
1264
+		$this->SetFont($fontName, '', $sizeTitle);
1265
+		$this->Cell(0, 5, $titre, 0, 1, 'C');
1266
+
1267
+		// set the good Font size for the bookmarks
1268
+		$this->SetFont($fontName, '', $sizeBookmark);
1269
+		$this->Ln(10);
1270
+
1271
+		// get the number of bookmarks
1272
+		$size=sizeof($this->outlines);
1273
+
1274
+		// get the size of the "P. xx" cell
1275
+		$pageCellSize=$this->GetStringWidth('p. '.$this->outlines[$size-1]['p'])+2;
1276
+
1277
+		// Foreach bookmark
1278
+		for ($i=0;$i<$size;$i++) {
1279
+			// if we need a new page => add a new page
1280
+			if ($this->getY()+$this->FontSize>=($this->h - $this->bMargin)) {
1281
+				$obj->_INDEX_NewPage($page);
1282
+				$this->SetFont($fontName, '', $sizeBookmark);
1283
+			}
1284
+
1285
+			// Offset of the current level
1286
+			$level=$this->outlines[$i]['l'];
1287
+			if($level>0) $this->Cell($level*8);
1288
+
1289
+			// Caption (cut to fit on the width page)
1290
+			$str=$this->outlines[$i]['t'];
1291
+			$strsize=$this->GetStringWidth($str);
1292
+			$availableSize=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-4;
1293
+			while ($strsize>=$availableSize) {
1294
+				$str=substr($str, 0, -1);
1295
+				$strsize=$this->GetStringWidth($str);
1296
+			}
1297
+
1298
+			// if we want to display the page nmber
1299
+			if ($displayPage) {
1300
+				// display the Bookmark Caption
1301
+				$this->Cell($strsize+2, $this->FontSize+2, $str);
1302
+
1303
+				//Filling dots
1304
+				$w=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-($strsize+2);
1305
+				$nb=$w/$this->GetStringWidth('.');
1306
+				$dots=str_repeat('.', $nb);
1307
+				$this->Cell($w, $this->FontSize+2, $dots, 0, 0, 'R');
1308
+
1309
+				//Page number
1310
+				$this->Cell($pageCellSize, $this->FontSize+2, 'p. '.$this->outlines[$i]['p'], 0, 1, 'R');
1311
+			} else {
1312
+				// display the Bookmark Caption
1313
+				$this->Cell($strsize+2, $this->FontSize+2, $str, 0, 1);
1314
+			}
1315
+		}
1316
+	}
1317
+
1318
+	/**
1319
+	 * Returns the string alias used for the total number of pages.
1320
+	 *
1321
+	 * @access public
1322
+	 * @return string;
1323
+	 * @see TCPDF::getAliasNbPages(), TCPDF::getPageGroupAlias()
1324
+	 */
1325
+	public function getMyAliasNbPages()
1326
+	{
1327
+		if ($this->_myLastPageGroupNb==0) {
1328
+			return $this->getAliasNbPages();
1329
+		} else {
1330
+			$old = $this->currpagegroup;
1331
+			$this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
1332
+			$new = $this->getPageGroupAlias();
1333
+			$this->currpagegroup = $old;
1334
+
1335
+			return $new;
1336
+		}
1337
+	}
1338
+
1339
+	/**
1340
+	 * Returns the current page number.
1341
+	 *
1342
+	 * @access public
1343
+	 * @param  integer $page
1344
+	 * @return integer;
1345
+	 */
1346
+	public function getMyNumPage($page=null)
1347
+	{
1348
+		if ($page===null) {
1349
+			$page = $this->page;
1350
+		}
1351
+
1352
+		if ($this->_myLastPageGroupNb==0) {
1353
+			return $page;
1354
+		} else {
1355
+			return $page-$this->_myLastPageGroup;
1356
+		}
1357
+	}
1358
+
1359
+	/**
1360
+	 * Start a new group of pages
1361
+	 *
1362
+	 * @access public
1363
+	 * @return integer;
1364
+	 * @see tcpdf::startPageGroup
1365
+	 */
1366
+	public function myStartPageGroup()
1367
+	{
1368
+		$this->_myLastPageGroup = $this->page-1;
1369
+		$this->_myLastPageGroupNb++;
1370
+	}
1371
+
1372
+	/**
1373
+	 * get $_myLastPageGroup;
1374
+	 *
1375
+	 * @access public
1376
+	 * @return integer $_myLastPageGroup;
1377
+	 */
1378
+	public function getMyLastPageGroup()
1379
+	{
1380
+		return $this->_myLastPageGroup;
1381
+	}
1382
+
1383
+	/**
1384
+	 * set $_myLastPageGroup;
1385
+	 *
1386
+	 * @access public
1387
+	 * @param integer $myLastPageGroup;
1388
+	 */
1389
+	public function setMyLastPageGroup($myLastPageGroup)
1390
+	{
1391
+		$this->_myLastPageGroup = $myLastPageGroup;
1392
+	}
1393
+
1394
+	/**
1395
+	 * get $_myLastPageGroupNb;
1396
+	 *
1397
+	 * @access public
1398
+	 * @return integer $_myLastPageGroupNb;
1399
+	 */
1400
+	public function getMyLastPageGroupNb()
1401
+	{
1402
+		return $this->_myLastPageGroupNb;
1403
+	}
1404
+
1405
+	/**
1406
+	 * set $_myLastPageGroupNb;
1407
+	 *
1408
+	 * @access public
1409
+	 * @param integer $myLastPageGroupNb;
1410
+	 */
1411
+	public function setMyLastPageGroupNb($myLastPageGroupNb)
1412
+	{
1413
+		$this->_myLastPageGroupNb = $myLastPageGroupNb;
1414
+	}
1415 1415
 }
Please login to merge, or discard this patch.
Spacing   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - myPdf class
4 4
  *
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @version   4.03
10 10
  */
11 11
 
12
-require_once(dirname(__FILE__).'/tcpdfConfig.php');
13
-require_once(dirname(__FILE__).'/../_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/tcpdf.php');
12
+require_once(dirname(__FILE__) . '/tcpdfConfig.php');
13
+require_once(dirname(__FILE__) . '/../_tcpdf_' . HTML2PDF_USED_TCPDF_VERSION . '/tcpdf.php');
14 14
 
15 15
 class HTML2PDF_myPdf extends TCPDF
16 16
 {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
      * @access public
38 38
      */
39 39
     public function __construct(
40
-        $orientation='P',
41
-        $unit='mm',
42
-        $format='A4',
43
-        $unicode=true,
44
-        $encoding='UTF-8',
45
-        $diskcache=false)
40
+        $orientation = 'P',
41
+        $unit = 'mm',
42
+        $format = 'A4',
43
+        $unicode = true,
44
+        $encoding = 'UTF-8',
45
+        $diskcache = false)
46 46
     {
47 47
         // call the parent constructor
48 48
         parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
             $txt = (HTML2PDF_locale::get('pdf05'));
94 94
         }
95 95
         if ($this->_footerParam['date'] && $this->_footerParam['hour']) {
96
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf03'));
96
+            $txt .= ($txt ? ' - ' : '') . (HTML2PDF_locale::get('pdf03'));
97 97
         }
98 98
         if ($this->_footerParam['date'] && !$this->_footerParam['hour']) {
99
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf01'));
99
+            $txt .= ($txt ? ' - ' : '') . (HTML2PDF_locale::get('pdf01'));
100 100
         }
101 101
         if (!$this->_footerParam['date'] && $this->_footerParam['hour']) {
102
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf02'));
102
+            $txt .= ($txt ? ' - ' : '') . (HTML2PDF_locale::get('pdf02'));
103 103
         }
104 104
         if ($this->_footerParam['page']) {
105
-            $txt.= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf04'));
105
+            $txt .= ($txt ? ' - ' : '') . (HTML2PDF_locale::get('pdf04'));
106 106
         }
107 107
 
108
-        if (strlen($txt)>0) {
108
+        if (strlen($txt) > 0) {
109 109
             // replace some values
110 110
             $toReplace = array(
111 111
                 '[[date_d]]'  => date('d'),
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
      * @param float word spacing
223 223
      * @access public
224 224
      */
225
-    public function setWordSpacing($ws=0.)
225
+    public function setWordSpacing($ws = 0.)
226 226
     {
227 227
         $this->ws = $ws;
228
-        $this->_out(sprintf('%.3F Tw', $ws*$this->k));
228
+        $this->_out(sprintf('%.3F Tw', $ws * $this->k));
229 229
     }
230 230
 
231 231
     /**
@@ -246,118 +246,118 @@  discard block
 block discarded – undo
246 246
         $y = null,
247 247
         $w = null,
248 248
         $h = null,
249
-        $cornerTL=null,
250
-        $cornerTR=null,
251
-        $cornerBL=null,
252
-        $cornerBR=null)
249
+        $cornerTL = null,
250
+        $cornerTR = null,
251
+        $cornerBL = null,
252
+        $cornerBR = null)
253 253
     {
254 254
         // init the path
255 255
         $path = '';
256 256
 
257 257
         // if we have the position and the size of the rectangle, we can proceed
258
-        if ($x!==null && $y!==null && $w!==null && $h!==null) {
258
+        if ($x !== null && $y !== null && $w !== null && $h !== null) {
259 259
             // the positions of the rectangle's corners
260
-            $x1 = $x*$this->k;
261
-            $y1 = ($this->h-$y)*$this->k;
260
+            $x1 = $x * $this->k;
261
+            $y1 = ($this->h - $y) * $this->k;
262 262
 
263
-            $x2 = ($x+$w)*$this->k;
264
-            $y2 = ($this->h-$y)*$this->k;
263
+            $x2 = ($x + $w) * $this->k;
264
+            $y2 = ($this->h - $y) * $this->k;
265 265
 
266
-            $x3 = ($x+$w)*$this->k;
267
-            $y3 = ($this->h-$y-$h)*$this->k;
266
+            $x3 = ($x + $w) * $this->k;
267
+            $y3 = ($this->h - $y - $h) * $this->k;
268 268
 
269
-            $x4 = $x*$this->k;
270
-            $y4 = ($this->h-$y-$h)*$this->k;
269
+            $x4 = $x * $this->k;
270
+            $y4 = ($this->h - $y - $h) * $this->k;
271 271
 
272 272
             // if we have at least one radius corner, then we proceed to a specific path, else it is just a rectangle
273 273
             if ($cornerTL || $cornerTR || $cornerBL || $cornerBR) {
274 274
                 // prepare the radius values
275 275
                 if ($cornerTL) {
276
-                    $cornerTL[0] = $cornerTL[0]*$this->k;
277
-                    $cornerTL[1] =-$cornerTL[1]*$this->k;
276
+                    $cornerTL[0] = $cornerTL[0] * $this->k;
277
+                    $cornerTL[1] = -$cornerTL[1] * $this->k;
278 278
                 }
279 279
                 if ($cornerTR) {
280
-                    $cornerTR[0] = $cornerTR[0]*$this->k;
281
-                    $cornerTR[1] =-$cornerTR[1]*$this->k;
280
+                    $cornerTR[0] = $cornerTR[0] * $this->k;
281
+                    $cornerTR[1] = -$cornerTR[1] * $this->k;
282 282
                 }
283 283
                 if ($cornerBL) {
284
-                    $cornerBL[0] = $cornerBL[0]*$this->k;
285
-                    $cornerBL[1] =-$cornerBL[1]*$this->k;
284
+                    $cornerBL[0] = $cornerBL[0] * $this->k;
285
+                    $cornerBL[1] = -$cornerBL[1] * $this->k;
286 286
                 }
287 287
                 if ($cornerBR) {
288
-                    $cornerBR[0] = $cornerBR[0]*$this->k;
289
-                    $cornerBR[1] =-$cornerBR[1]*$this->k;
288
+                    $cornerBR[0] = $cornerBR[0] * $this->k;
289
+                    $cornerBR[1] = -$cornerBR[1] * $this->k;
290 290
                 }
291 291
 
292 292
                 // if TL radius then specific start else (X1,Y1)
293 293
                 if ($cornerTL) {
294
-                    $path.= sprintf('%.2F %.2F m ', $x1+$cornerTL[0], $y1);
294
+                    $path .= sprintf('%.2F %.2F m ', $x1 + $cornerTL[0], $y1);
295 295
                 } else {
296
-                    $path.= sprintf('%.2F %.2F m ', $x1, $y1);
296
+                    $path .= sprintf('%.2F %.2F m ', $x1, $y1);
297 297
                 }
298 298
 
299 299
                 // if TR radius then line + arc, else line to (X2,Y2)
300 300
                 if ($cornerTR) {
301
-                    $xt1 = ($x2-$cornerTR[0])+$cornerTR[0]*self::MY_ARC;
302
-                    $yt1 = ($y2+$cornerTR[1])-$cornerTR[1];
303
-                    $xt2 = ($x2-$cornerTR[0])+$cornerTR[0];
304
-                    $yt2 = ($y2+$cornerTR[1])-$cornerTR[1]*self::MY_ARC;
301
+                    $xt1 = ($x2 - $cornerTR[0]) + $cornerTR[0] * self::MY_ARC;
302
+                    $yt1 = ($y2 + $cornerTR[1]) - $cornerTR[1];
303
+                    $xt2 = ($x2 - $cornerTR[0]) + $cornerTR[0];
304
+                    $yt2 = ($y2 + $cornerTR[1]) - $cornerTR[1] * self::MY_ARC;
305 305
 
306
-                    $path.= sprintf('%.2F %.2F l ', $x2-$cornerTR[0], $y2);
307
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2+$cornerTR[1]);
306
+                    $path .= sprintf('%.2F %.2F l ', $x2 - $cornerTR[0], $y2);
307
+                    $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2 + $cornerTR[1]);
308 308
                 } else {
309
-                    $path.= sprintf('%.2F %.2F l ', $x2, $y2);
309
+                    $path .= sprintf('%.2F %.2F l ', $x2, $y2);
310 310
                 }
311 311
 
312 312
                 // if BR radius then line + arc, else line to (X3, Y3)
313 313
                 if ($cornerBR) {
314
-                    $xt1 = ($x3-$cornerBR[0])+$cornerBR[0];
315
-                    $yt1 = ($y3-$cornerBR[1])+$cornerBR[1]*self::MY_ARC;
316
-                    $xt2 = ($x3-$cornerBR[0])+$cornerBR[0]*self::MY_ARC;
317
-                    $yt2 = ($y3-$cornerBR[1])+$cornerBR[1];
314
+                    $xt1 = ($x3 - $cornerBR[0]) + $cornerBR[0];
315
+                    $yt1 = ($y3 - $cornerBR[1]) + $cornerBR[1] * self::MY_ARC;
316
+                    $xt2 = ($x3 - $cornerBR[0]) + $cornerBR[0] * self::MY_ARC;
317
+                    $yt2 = ($y3 - $cornerBR[1]) + $cornerBR[1];
318 318
 
319
-                    $path.= sprintf('%.2F %.2F l ', $x3, $y3-$cornerBR[1]);
320
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3-$cornerBR[0], $y3);
319
+                    $path .= sprintf('%.2F %.2F l ', $x3, $y3 - $cornerBR[1]);
320
+                    $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3 - $cornerBR[0], $y3);
321 321
                 } else {
322
-                    $path.= sprintf('%.2F %.2F l ', $x3, $y3);
322
+                    $path .= sprintf('%.2F %.2F l ', $x3, $y3);
323 323
                 }
324 324
 
325 325
                 // if BL radius then line + arc, else line to (X4, Y4)
326 326
                 if ($cornerBL) {
327
-                    $xt1 = ($x4+$cornerBL[0])-$cornerBL[0]*self::MY_ARC;
328
-                    $yt1 = ($y4-$cornerBL[1])+$cornerBL[1];
329
-                    $xt2 = ($x4+$cornerBL[0])-$cornerBL[0];
330
-                    $yt2 = ($y4-$cornerBL[1])+$cornerBL[1]*self::MY_ARC;
327
+                    $xt1 = ($x4 + $cornerBL[0]) - $cornerBL[0] * self::MY_ARC;
328
+                    $yt1 = ($y4 - $cornerBL[1]) + $cornerBL[1];
329
+                    $xt2 = ($x4 + $cornerBL[0]) - $cornerBL[0];
330
+                    $yt2 = ($y4 - $cornerBL[1]) + $cornerBL[1] * self::MY_ARC;
331 331
 
332
-                    $path.= sprintf('%.2F %.2F l ', $x4+$cornerBL[0], $y4);
333
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4-$cornerBL[1]);
332
+                    $path .= sprintf('%.2F %.2F l ', $x4 + $cornerBL[0], $y4);
333
+                    $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4 - $cornerBL[1]);
334 334
                 } else {
335
-                    $path.= sprintf('%.2F %.2F l ', $x4, $y4);
335
+                    $path .= sprintf('%.2F %.2F l ', $x4, $y4);
336 336
                 }
337 337
 
338 338
                 // if RL radius then line + arc
339 339
                 if ($cornerTL) {
340
-                    $xt1 = ($x1+$cornerTL[0])-$cornerTL[0];
341
-                    $yt1 = ($y1+$cornerTL[1])-$cornerTL[1]*self::MY_ARC;
342
-                    $xt2 = ($x1+$cornerTL[0])-$cornerTL[0]*self::MY_ARC;
343
-                    $yt2 = ($y1+$cornerTL[1])-$cornerTL[1];
340
+                    $xt1 = ($x1 + $cornerTL[0]) - $cornerTL[0];
341
+                    $yt1 = ($y1 + $cornerTL[1]) - $cornerTL[1] * self::MY_ARC;
342
+                    $xt2 = ($x1 + $cornerTL[0]) - $cornerTL[0] * self::MY_ARC;
343
+                    $yt2 = ($y1 + $cornerTL[1]) - $cornerTL[1];
344 344
 
345
-                    $path.= sprintf('%.2F %.2F l ', $x1, $y1+$cornerTL[1]);
346
-                    $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1+$cornerTL[0], $y1);
345
+                    $path .= sprintf('%.2F %.2F l ', $x1, $y1 + $cornerTL[1]);
346
+                    $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1 + $cornerTL[0], $y1);
347 347
                 }
348 348
             } else {
349
-                $path.= sprintf('%.2F %.2F m ', $x1, $y1);
350
-                $path.= sprintf('%.2F %.2F l ', $x2, $y2);
351
-                $path.= sprintf('%.2F %.2F l ', $x3, $y3);
352
-                $path.= sprintf('%.2F %.2F l ', $x4, $y4);
349
+                $path .= sprintf('%.2F %.2F m ', $x1, $y1);
350
+                $path .= sprintf('%.2F %.2F l ', $x2, $y2);
351
+                $path .= sprintf('%.2F %.2F l ', $x3, $y3);
352
+                $path .= sprintf('%.2F %.2F l ', $x4, $y4);
353 353
             }
354 354
 
355 355
             // close the path
356
-            $path.= ' h W n';
356
+            $path .= ' h W n';
357 357
         }
358 358
 
359 359
         // using the path as a clipping path
360
-        $this->_out('q '.$path.' ');
360
+        $this->_out('q ' . $path . ' ');
361 361
     }
362 362
 
363 363
     /**
@@ -396,48 +396,48 @@  discard block
 block discarded – undo
396 396
     public function drawCurve($ext1X, $ext1Y, $ext2X, $ext2Y, $int1X, $int1Y, $int2X, $int2Y, $cenX, $cenY)
397 397
     {
398 398
         // prepare the coordinates
399
-        $ext1X = $ext1X*$this->k;
400
-        $ext2X = $ext2X*$this->k;
401
-        $int1X = $int1X*$this->k;
402
-        $int2X = $int2X*$this->k;
403
-        $cenX  = $cenX*$this->k;
404
-
405
-        $ext1Y = ($this->h-$ext1Y)*$this->k;
406
-        $ext2Y = ($this->h-$ext2Y)*$this->k;
407
-        $int1Y = ($this->h-$int1Y)*$this->k;
408
-        $int2Y = ($this->h-$int2Y)*$this->k;
409
-        $cenY  = ($this->h-$cenY) *$this->k;
399
+        $ext1X = $ext1X * $this->k;
400
+        $ext2X = $ext2X * $this->k;
401
+        $int1X = $int1X * $this->k;
402
+        $int2X = $int2X * $this->k;
403
+        $cenX  = $cenX * $this->k;
404
+
405
+        $ext1Y = ($this->h - $ext1Y) * $this->k;
406
+        $ext2Y = ($this->h - $ext2Y) * $this->k;
407
+        $int1Y = ($this->h - $int1Y) * $this->k;
408
+        $int2Y = ($this->h - $int2Y) * $this->k;
409
+        $cenY  = ($this->h - $cenY) * $this->k;
410 410
 
411 411
         // init the curve
412 412
         $path = '';
413 413
 
414
-        if ($ext1X-$cenX!=0) {
415
-            $xt1 = $cenX+($ext1X-$cenX);
416
-            $yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
417
-            $xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
418
-            $yt2 = $cenY+($ext2Y-$cenY);
414
+        if ($ext1X - $cenX != 0) {
415
+            $xt1 = $cenX + ($ext1X - $cenX);
416
+            $yt1 = $cenY + ($ext2Y - $cenY) * self::MY_ARC;
417
+            $xt2 = $cenX + ($ext1X - $cenX) * self::MY_ARC;
418
+            $yt2 = $cenY + ($ext2Y - $cenY);
419 419
         } else {
420
-            $xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
421
-            $yt1 = $cenY+($ext1Y-$cenY);
422
-            $xt2 = $cenX+($ext2X-$cenX);
423
-            $yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
420
+            $xt1 = $cenX + ($ext2X - $cenX) * self::MY_ARC;
421
+            $yt1 = $cenY + ($ext1Y - $cenY);
422
+            $xt2 = $cenX + ($ext2X - $cenX);
423
+            $yt2 = $cenY + ($ext1Y - $cenY) * self::MY_ARC;
424 424
         }
425
-        $path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
426
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
427
-
428
-        if ($int1X-$cenX!=0) {
429
-            $xt1 = $cenX+($int1X-$cenX)*self::MY_ARC;
430
-            $yt1 = $cenY+($int2Y-$cenY);
431
-            $xt2 = $cenX+($int1X-$cenX);
432
-            $yt2 = $cenY+($int2Y-$cenY)*self::MY_ARC;
425
+        $path .= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
426
+        $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
427
+
428
+        if ($int1X - $cenX != 0) {
429
+            $xt1 = $cenX + ($int1X - $cenX) * self::MY_ARC;
430
+            $yt1 = $cenY + ($int2Y - $cenY);
431
+            $xt2 = $cenX + ($int1X - $cenX);
432
+            $yt2 = $cenY + ($int2Y - $cenY) * self::MY_ARC;
433 433
         } else {
434
-            $xt1 = $cenX+($int2X-$cenX);
435
-            $yt1 = $cenY+($int1Y-$cenY)*self::MY_ARC;
436
-            $xt2 = $cenX+($int2X-$cenX)*self::MY_ARC;
437
-            $yt2 = $cenY+($int1Y-$cenY);
434
+            $xt1 = $cenX + ($int2X - $cenX);
435
+            $yt1 = $cenY + ($int1Y - $cenY) * self::MY_ARC;
436
+            $xt2 = $cenX + ($int2X - $cenX) * self::MY_ARC;
437
+            $yt2 = $cenY + ($int1Y - $cenY);
438 438
         }
439
-        $path.= sprintf('%.2F %.2F l ', $int2X, $int2Y);
440
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1X, $int1Y);
439
+        $path .= sprintf('%.2F %.2F l ', $int2X, $int2Y);
440
+        $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1X, $int1Y);
441 441
 
442 442
         // draw the curve
443 443
         $this->_out($path . 'f');
@@ -467,34 +467,34 @@  discard block
 block discarded – undo
467 467
     public function drawCorner($ext1X, $ext1Y, $ext2X, $ext2Y, $intX, $intY, $cenX, $cenY)
468 468
     {
469 469
         // prepare the coordinates
470
-        $ext1X = $ext1X*$this->k;
471
-        $ext2X = $ext2X*$this->k;
472
-        $intX  = $intX*$this->k;
473
-        $cenX  = $cenX*$this->k;
470
+        $ext1X = $ext1X * $this->k;
471
+        $ext2X = $ext2X * $this->k;
472
+        $intX  = $intX * $this->k;
473
+        $cenX  = $cenX * $this->k;
474 474
 
475
-        $ext1Y = ($this->h-$ext1Y)*$this->k;
476
-        $ext2Y = ($this->h-$ext2Y)*$this->k;
477
-        $intY  = ($this->h-$intY)*$this->k;
478
-        $cenY  = ($this->h-$cenY)*$this->k;
475
+        $ext1Y = ($this->h - $ext1Y) * $this->k;
476
+        $ext2Y = ($this->h - $ext2Y) * $this->k;
477
+        $intY  = ($this->h - $intY) * $this->k;
478
+        $cenY  = ($this->h - $cenY) * $this->k;
479 479
 
480 480
         // init the curve
481 481
         $path = '';
482 482
 
483
-        if ($ext1X-$cenX!=0) {
484
-            $xt1 = $cenX+($ext1X-$cenX);
485
-            $yt1 = $cenY+($ext2Y-$cenY)*self::MY_ARC;
486
-            $xt2 = $cenX+($ext1X-$cenX)*self::MY_ARC;
487
-            $yt2 = $cenY+($ext2Y-$cenY);
483
+        if ($ext1X - $cenX != 0) {
484
+            $xt1 = $cenX + ($ext1X - $cenX);
485
+            $yt1 = $cenY + ($ext2Y - $cenY) * self::MY_ARC;
486
+            $xt2 = $cenX + ($ext1X - $cenX) * self::MY_ARC;
487
+            $yt2 = $cenY + ($ext2Y - $cenY);
488 488
         } else {
489
-            $xt1 = $cenX+($ext2X-$cenX)*self::MY_ARC;
490
-            $yt1 = $cenY+($ext1Y-$cenY);
491
-            $xt2 = $cenX+($ext2X-$cenX);
492
-            $yt2 = $cenY+($ext1Y-$cenY)*self::MY_ARC;
489
+            $xt1 = $cenX + ($ext2X - $cenX) * self::MY_ARC;
490
+            $yt1 = $cenY + ($ext1Y - $cenY);
491
+            $xt2 = $cenX + ($ext2X - $cenX);
492
+            $yt2 = $cenY + ($ext1Y - $cenY) * self::MY_ARC;
493 493
         }
494
-        $path.= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
495
-        $path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
496
-        $path.= sprintf('%.2F %.2F l ', $intX, $intY);
497
-        $path.= sprintf('%.2F %.2F l ', $ext1X, $ext1Y);
494
+        $path .= sprintf('%.2F %.2F m ', $ext1X, $ext1Y);
495
+        $path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y);
496
+        $path .= sprintf('%.2F %.2F l ', $intX, $intY);
497
+        $path .= sprintf('%.2F %.2F l ', $ext1X, $ext1Y);
498 498
 
499 499
         // draw the curve
500 500
         $this->_out($path . 'f');
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
     public function setTranslate($xT, $yT)
531 531
     {
532 532
         // Matrix for Translate
533
-        $tm[0]=1;
534
-        $tm[1]=0;
535
-        $tm[2]=0;
536
-        $tm[3]=1;
537
-        $tm[4]=$xT*$this->k;
538
-        $tm[5]=-$yT*$this->k;
533
+        $tm[0] = 1;
534
+        $tm[1] = 0;
535
+        $tm[2] = 0;
536
+        $tm[3] = 1;
537
+        $tm[4] = $xT * $this->k;
538
+        $tm[5] = -$yT * $this->k;
539 539
 
540 540
         // apply the Transform Matric
541 541
         $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
@@ -549,23 +549,23 @@  discard block
 block discarded – undo
549 549
      * @param float $Cy
550 550
      * @access public
551 551
      */
552
-    public function setRotation($angle, $xC=null, $yC=null)
552
+    public function setRotation($angle, $xC = null, $yC = null)
553 553
     {
554 554
         // if no center, rotate around the current posiition
555
-        if($xC === null) $xC=$this->x;
556
-        if($yC === null) $yC=$this->y;
555
+        if ($xC === null) $xC = $this->x;
556
+        if ($yC === null) $yC = $this->y;
557 557
 
558 558
         // prepare the coordinate
559
-        $yC=($this->h-$yC)*$this->k;
560
-        $xC*=$this->k;
559
+        $yC = ($this->h - $yC) * $this->k;
560
+        $xC *= $this->k;
561 561
 
562 562
         // Matrix for Rotate
563
-        $tm[0]=cos(deg2rad($angle));
564
-        $tm[1]=sin(deg2rad($angle));
565
-        $tm[2]=-$tm[1];
566
-        $tm[3]=$tm[0];
567
-        $tm[4]=$xC+$tm[1]*$yC-$tm[0]*$xC;
568
-        $tm[5]=$yC-$tm[0]*$yC-$tm[1]*$xC;
563
+        $tm[0] = cos(deg2rad($angle));
564
+        $tm[1] = sin(deg2rad($angle));
565
+        $tm[2] = -$tm[1];
566
+        $tm[3] = $tm[0];
567
+        $tm[4] = $xC + $tm[1] * $yC - $tm[0] * $xC;
568
+        $tm[5] = $yC - $tm[0] * $yC - $tm[1] * $xC;
569 569
 
570 570
         // apply the Transform Matric
571 571
         $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
      * @param boolean $rtloff NOT USED
580 580
      * @access public
581 581
      */
582
-    public function SetX($x, $rtloff=false)
582
+    public function SetX($x, $rtloff = false)
583 583
     {
584
-        $this->x=$x;
584
+        $this->x = $x;
585 585
     }
586 586
 
587 587
     /**
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
      * @param boolean $rtloff NOT USED
594 594
      * @access public
595 595
      */
596
-    public function SetY($y, $resetx=true, $rtloff=false)
596
+    public function SetY($y, $resetx = true, $rtloff = false)
597 597
     {
598 598
         if ($resetx)
599
-            $this->x=$this->lMargin;
599
+            $this->x = $this->lMargin;
600 600
 
601
-        $this->y=$y;
601
+        $this->y = $y;
602 602
     }
603 603
 
604 604
     /**
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
      * @param boolean $rtloff NOT USED
611 611
      * @access public
612 612
      */
613
-    public function SetXY($x, $y, $rtloff=false)
613
+    public function SetXY($x, $y, $rtloff = false)
614 614
     {
615
-        $this->x=$x;
616
-        $this->y=$y;
615
+        $this->x = $x;
616
+        $this->y = $y;
617 617
     }
618 618
 
619 619
     /**
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
     }
654 654
     public function setbMargin($v)
655 655
     {
656
-        $this->bMargin=$v;
656
+        $this->bMargin = $v;
657 657
     }
658 658
 
659 659
     /**
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
         // Style : fill
672 672
         if ($styles['fill']) {
673 673
             $this->setFillColorArray($styles['fill']);
674
-            $style.= 'F';
674
+            $style .= 'F';
675 675
         }
676 676
 
677 677
         // Style : stroke
678 678
         if ($styles['stroke'] && $styles['stroke-width']) {
679 679
             $this->SetDrawColorArray($styles['stroke']);
680 680
             $this->SetLineWidth($styles['stroke-width']);
681
-            $style.= 'D';
681
+            $style .= 'D';
682 682
         }
683 683
 
684 684
         // Style : opacity
@@ -702,20 +702,20 @@  discard block
 block discarded – undo
702 702
     public function svgRect($x, $y, $w, $h, $style)
703 703
     {
704 704
         // prepare the 4 corners
705
-        $x1=$x;
706
-        $x2=$x+$w;
707
-        $x3=$x+$w;
708
-        $x4=$x;
705
+        $x1 = $x;
706
+        $x2 = $x + $w;
707
+        $x3 = $x + $w;
708
+        $x4 = $x;
709 709
 
710
-        $y1=$y;
711
-        $y2=$y;
712
-        $y3=$y+$h;
713
-        $y4=$y+$h;
710
+        $y1 = $y;
711
+        $y2 = $y;
712
+        $y3 = $y + $h;
713
+        $y4 = $y + $h;
714 714
 
715 715
         // get the Closing operator from the PDF Style
716
-        if($style=='F') $op='f';
717
-        elseif($style=='FD' || $style=='DF') $op='B';
718
-        else $op='S';
716
+        if ($style == 'F') $op = 'f';
717
+        elseif ($style == 'FD' || $style == 'DF') $op = 'B';
718
+        else $op = 'S';
719 719
 
720 720
         // drawing
721 721
         $this->_Point($x1, $y1, true);
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
     public function svgLine($x1, $y1, $x2, $y2)
739 739
     {
740 740
         // get the Closing operator
741
-        $op='S';
741
+        $op = 'S';
742 742
 
743 743
         // drawing
744 744
         $this->_Point($x1, $y1, true);
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
     public function svgEllipse($x0, $y0, $rx, $ry, $style)
760 760
     {
761 761
         // get the Closing operator from the PDF Style
762
-        if($style=='F') $op='f';
763
-        elseif($style=='FD' || $style=='DF') $op='B';
764
-        else $op='S';
762
+        if ($style == 'F') $op = 'f';
763
+        elseif ($style == 'FD' || $style == 'DF') $op = 'B';
764
+        else $op = 'S';
765 765
 
766 766
         // drawing
767
-        $this->_Arc($x0, $y0, $rx, $ry, 0, 2*M_PI, true, true, true);
767
+        $this->_Arc($x0, $y0, $rx, $ry, 0, 2 * M_PI, true, true, true);
768 768
         $this->_out($op);
769 769
     }
770 770
 
@@ -778,16 +778,16 @@  discard block
 block discarded – undo
778 778
     public function svgPolygone($actions, $style)
779 779
     {
780 780
         // get the Closing operator from the PDF Style
781
-        if($style=='F') $op='f';
782
-        elseif($style=='FD' || $style=='DF') $op='B';
783
-        else $op='S';
781
+        if ($style == 'F') $op = 'f';
782
+        elseif ($style == 'FD' || $style == 'DF') $op = 'B';
783
+        else $op = 'S';
784 784
 
785 785
         // To save the First action and the last point
786 786
         $first = array('', 0, 0);
787 787
         $last = array(0, 0, 0, 0);
788 788
 
789 789
         foreach ($actions as $action) {
790
-            switch($action[0])
790
+            switch ($action[0])
791 791
             {
792 792
                 // Start the Path
793 793
                 case 'M':
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 
813 813
                 // Make a Line (vector from last point)
814 814
                 case 'l':
815
-                    $x = $last[0]+$action[1]; $y = $last[1]+$action[2]; $xc = $x; $yc = $y;
815
+                    $x = $last[0] + $action[1]; $y = $last[1] + $action[2]; $xc = $x; $yc = $y;
816 816
                     $this->_Line($x, $y, true);
817 817
                     break;
818 818
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 
825 825
                 // Make a Horisontal Line (vector from last point)
826 826
                 case 'h':
827
-                    $x = $last[0]+$action[1]; $y = $last[1]; $xc = $x; $yc = $y;
827
+                    $x = $last[0] + $action[1]; $y = $last[1]; $xc = $x; $yc = $y;
828 828
                     $this->_Line($x, $y, true);
829 829
                     break;
830 830
 
@@ -836,21 +836,21 @@  discard block
 block discarded – undo
836 836
 
837 837
                 // Make a Vertical Line (vector from last point)
838 838
                 case 'v':
839
-                    $x = $last[0]; $y = $last[1]+$action[1]; $xc = $x; $yc = $y;
839
+                    $x = $last[0]; $y = $last[1] + $action[1]; $xc = $x; $yc = $y;
840 840
                     $this->_Line($x, $y, true);
841 841
                     break;
842 842
 
843 843
                 // Make a Arc (new point)
844 844
                 case 'A':
845
-                    $rx = $action[1];   // rx
846
-                    $ry = $action[2];   // ry
847
-                    $a = $action[3];    // deviation angle of the axis X
848
-                    $l = $action[4];    // large-arc-flag
849
-                    $s = $action[5];    // sweep-flag
850
-                    $x1 = $last[0];     // begin x
851
-                    $y1 = $last[1];     // begin y
852
-                    $x2 = $action[6];   // final x
853
-                    $y2 = $action[7];   // final y
845
+                    $rx = $action[1]; // rx
846
+                    $ry = $action[2]; // ry
847
+                    $a = $action[3]; // deviation angle of the axis X
848
+                    $l = $action[4]; // large-arc-flag
849
+                    $s = $action[5]; // sweep-flag
850
+                    $x1 = $last[0]; // begin x
851
+                    $y1 = $last[1]; // begin y
852
+                    $x2 = $action[6]; // final x
853
+                    $y2 = $action[7]; // final y
854 854
 
855 855
                     $this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
856 856
                     $x = $x2; $y = $y2; $xc = $x; $yc = $y;
@@ -858,15 +858,15 @@  discard block
 block discarded – undo
858 858
 
859 859
                 // Make a Arc (vector from last point)
860 860
                 case 'a':
861
-                    $rx = $action[1];   // rx
862
-                    $ry = $action[2];   // ry
863
-                    $a = $action[3];    // deviation angle of the axis X
864
-                    $l = $action[4];    // large-arc-flag
865
-                    $s = $action[5];    // sweep-flag
866
-                    $x1 = $last[0];     // begin x
867
-                    $y1 = $last[1];     // begin y
868
-                    $x2 = $last[0]+$action[6]; // final x
869
-                    $y2 = $last[1]+$action[7]; // final y
861
+                    $rx = $action[1]; // rx
862
+                    $ry = $action[2]; // ry
863
+                    $a = $action[3]; // deviation angle of the axis X
864
+                    $l = $action[4]; // large-arc-flag
865
+                    $s = $action[5]; // sweep-flag
866
+                    $x1 = $last[0]; // begin x
867
+                    $y1 = $last[1]; // begin y
868
+                    $x2 = $last[0] + $action[6]; // final x
869
+                    $y2 = $last[1] + $action[7]; // final y
870 870
 
871 871
                     $this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true);
872 872
                     $x = $x2; $y = $y2; $xc = $x; $yc = $y;
@@ -886,19 +886,19 @@  discard block
 block discarded – undo
886 886
 
887 887
                 // Make a Bezier Curve (vector from last point)
888 888
                 case 'c':
889
-                    $x1 = $last[0]+$action[1];
890
-                    $y1 = $last[1]+$action[2];
891
-                    $x2 = $last[0]+$action[3];
892
-                    $y2 = $last[1]+$action[4];
893
-                    $xf = $last[0]+$action[5];
894
-                    $yf = $last[1]+$action[6];
889
+                    $x1 = $last[0] + $action[1];
890
+                    $y1 = $last[1] + $action[2];
891
+                    $x2 = $last[0] + $action[3];
892
+                    $y2 = $last[1] + $action[4];
893
+                    $xf = $last[0] + $action[5];
894
+                    $yf = $last[1] + $action[6];
895 895
                     $this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true);
896 896
                     $x = $xf; $y = $yf; $xc = $x2; $yc = $y2;
897 897
                     break;
898 898
 
899 899
                 // Unknown Path
900 900
                 default:
901
-                    throw new HTML2PDF_exception(0, 'SVG Path Error : ['.$action[0].'] unkown');
901
+                    throw new HTML2PDF_exception(0, 'SVG Path Error : [' . $action[0] . '] unkown');
902 902
             }
903 903
 
904 904
             // save the last point
@@ -984,14 +984,14 @@  discard block
 block discarded – undo
984 984
         $angleEnd,
985 985
         $direction = true,
986 986
         $drawFirst = true,
987
-        $trans=false)
987
+        $trans = false)
988 988
     {
989 989
         // if we want the no trigo direction : add 2PI to the begin angle, to invert the direction
990
-        if (!$direction) $angleBegin+= M_PI*2.;
990
+        if (!$direction) $angleBegin += M_PI * 2.;
991 991
 
992 992
         // cut in segment to convert in berize curv
993
-        $dt = ($angleEnd - $angleBegin)/self::ARC_NB_SEGMENT;
994
-        $dtm = $dt/3;
993
+        $dt = ($angleEnd - $angleBegin) / self::ARC_NB_SEGMENT;
994
+        $dtm = $dt / 3;
995 995
 
996 996
         // center of the arc
997 997
         $x0 = $xc; $y0 = $yc;
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
         // foreach segment
1010 1010
         for ($i = 1; $i <= self::ARC_NB_SEGMENT; $i++) {
1011 1011
             // calculing the next point
1012
-            $t1 = ($i * $dt)+$angleBegin;
1012
+            $t1 = ($i * $dt) + $angleBegin;
1013 1013
             $a1 = $x0 + ($rx * cos($t1));
1014 1014
             $b1 = $y0 + ($ry * sin($t1));
1015 1015
             $c1 = -$rx * sin($t1);
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
      * @param boolean $trans apply transformation
1047 1047
      * @access protected
1048 1048
      */
1049
-    protected function _Arc2($x1, $y1, $x2, $y2, $rx, $ry, $angle=0., $l=0, $s=0, $trans = false)
1049
+    protected function _Arc2($x1, $y1, $x2, $y2, $rx, $ry, $angle = 0., $l = 0, $s = 0, $trans = false)
1050 1050
     {
1051 1051
         // array to stock the parameters
1052 1052
         $v = array();
@@ -1060,50 +1060,50 @@  discard block
 block discarded – undo
1060 1060
         $v['ry'] = $ry;
1061 1061
 
1062 1062
         // rotate with the deviation angle of the axis X
1063
-        $v['xr1'] = $v['x1']*cos($angle) - $v['y1']*sin($angle);
1064
-        $v['yr1'] = $v['x1']*sin($angle) + $v['y1']*cos($angle);
1065
-        $v['xr2'] = $v['x2']*cos($angle) - $v['y2']*sin($angle);
1066
-        $v['yr2'] = $v['x2']*sin($angle) + $v['y2']*cos($angle);
1063
+        $v['xr1'] = $v['x1'] * cos($angle) - $v['y1'] * sin($angle);
1064
+        $v['yr1'] = $v['x1'] * sin($angle) + $v['y1'] * cos($angle);
1065
+        $v['xr2'] = $v['x2'] * cos($angle) - $v['y2'] * sin($angle);
1066
+        $v['yr2'] = $v['x2'] * sin($angle) + $v['y2'] * cos($angle);
1067 1067
 
1068 1068
         // the normalized vector
1069
-        $v['Xr1'] = $v['xr1']/$v['rx'];
1070
-        $v['Yr1'] = $v['yr1']/$v['ry'];
1071
-        $v['Xr2'] = $v['xr2']/$v['rx'];
1072
-        $v['Yr2'] = $v['yr2']/$v['ry'];
1073
-        $v['dXr'] = $v['Xr2']-$v['Xr1'];
1074
-        $v['dYr'] = $v['Yr2']-$v['Yr1'];
1075
-        $v['D'] = $v['dXr']*$v['dXr'] + $v['dYr']*$v['dYr'];
1069
+        $v['Xr1'] = $v['xr1'] / $v['rx'];
1070
+        $v['Yr1'] = $v['yr1'] / $v['ry'];
1071
+        $v['Xr2'] = $v['xr2'] / $v['rx'];
1072
+        $v['Yr2'] = $v['yr2'] / $v['ry'];
1073
+        $v['dXr'] = $v['Xr2'] - $v['Xr1'];
1074
+        $v['dYr'] = $v['Yr2'] - $v['Yr1'];
1075
+        $v['D'] = $v['dXr'] * $v['dXr'] + $v['dYr'] * $v['dYr'];
1076 1076
 
1077 1077
         // if |vector| is Null, or if |vector| > 2 : impossible to make a arc => Line
1078
-        if ($v['D']==0 || $v['D']>4) {
1078
+        if ($v['D'] == 0 || $v['D'] > 4) {
1079 1079
             $this->_Line($x2, $y2, $trans);
1080 1080
             return false;
1081 1081
         }
1082 1082
 
1083 1083
         // convert paramters for make a arc with Center, Radius, from angleBegin to angleEnd
1084 1084
         $v['s1'] = array();
1085
-        $v['s1']['t'] = sqrt((4.-$v['D'])/$v['D']);
1086
-        $v['s1']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s1']['t']*($v['Yr2']-$v['Yr1'])/2.;
1087
-        $v['s1']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s1']['t']*($v['Xr1']-$v['Xr2'])/2.;
1088
-        $v['s1']['xr'] = $v['s1']['Xr']*$v['rx'];
1089
-        $v['s1']['yr'] = $v['s1']['Yr']*$v['ry'];
1090
-        $v['s1']['x'] = $v['s1']['xr']*cos($angle)+$v['s1']['yr']*sin($angle);
1091
-        $v['s1']['y'] =-$v['s1']['xr']*sin($angle)+$v['s1']['yr']*cos($angle);
1092
-        $v['s1']['a1'] = atan2($v['y1']-$v['s1']['y'], $v['x1']-$v['s1']['x']);
1093
-        $v['s1']['a2'] = atan2($v['y2']-$v['s1']['y'], $v['x2']-$v['s1']['x']);
1094
-        if ($v['s1']['a1']>$v['s1']['a2']) $v['s1']['a1']-=2*M_PI;
1085
+        $v['s1']['t'] = sqrt((4. - $v['D']) / $v['D']);
1086
+        $v['s1']['Xr'] = ($v['Xr1'] + $v['Xr2']) / 2. + $v['s1']['t'] * ($v['Yr2'] - $v['Yr1']) / 2.;
1087
+        $v['s1']['Yr'] = ($v['Yr1'] + $v['Yr2']) / 2. + $v['s1']['t'] * ($v['Xr1'] - $v['Xr2']) / 2.;
1088
+        $v['s1']['xr'] = $v['s1']['Xr'] * $v['rx'];
1089
+        $v['s1']['yr'] = $v['s1']['Yr'] * $v['ry'];
1090
+        $v['s1']['x'] = $v['s1']['xr'] * cos($angle) + $v['s1']['yr'] * sin($angle);
1091
+        $v['s1']['y'] = -$v['s1']['xr'] * sin($angle) + $v['s1']['yr'] * cos($angle);
1092
+        $v['s1']['a1'] = atan2($v['y1'] - $v['s1']['y'], $v['x1'] - $v['s1']['x']);
1093
+        $v['s1']['a2'] = atan2($v['y2'] - $v['s1']['y'], $v['x2'] - $v['s1']['x']);
1094
+        if ($v['s1']['a1'] > $v['s1']['a2']) $v['s1']['a1'] -= 2 * M_PI;
1095 1095
 
1096 1096
         $v['s2'] = array();
1097 1097
         $v['s2']['t'] = -$v['s1']['t'];
1098
-        $v['s2']['Xr'] = ($v['Xr1']+$v['Xr2'])/2. + $v['s2']['t']*($v['Yr2']-$v['Yr1'])/2.;
1099
-        $v['s2']['Yr'] = ($v['Yr1']+$v['Yr2'])/2. + $v['s2']['t']*($v['Xr1']-$v['Xr2'])/2.;
1100
-        $v['s2']['xr'] = $v['s2']['Xr']*$v['rx'];
1101
-        $v['s2']['yr'] = $v['s2']['Yr']*$v['ry'];
1102
-        $v['s2']['x'] = $v['s2']['xr']*cos($angle)+$v['s2']['yr']*sin($angle);
1103
-        $v['s2']['y'] =-$v['s2']['xr']*sin($angle)+$v['s2']['yr']*cos($angle);
1104
-        $v['s2']['a1'] = atan2($v['y1']-$v['s2']['y'], $v['x1']-$v['s2']['x']);
1105
-        $v['s2']['a2'] = atan2($v['y2']-$v['s2']['y'], $v['x2']-$v['s2']['x']);
1106
-        if ($v['s2']['a1']>$v['s2']['a2']) $v['s2']['a1']-=2*M_PI;
1098
+        $v['s2']['Xr'] = ($v['Xr1'] + $v['Xr2']) / 2. + $v['s2']['t'] * ($v['Yr2'] - $v['Yr1']) / 2.;
1099
+        $v['s2']['Yr'] = ($v['Yr1'] + $v['Yr2']) / 2. + $v['s2']['t'] * ($v['Xr1'] - $v['Xr2']) / 2.;
1100
+        $v['s2']['xr'] = $v['s2']['Xr'] * $v['rx'];
1101
+        $v['s2']['yr'] = $v['s2']['Yr'] * $v['ry'];
1102
+        $v['s2']['x'] = $v['s2']['xr'] * cos($angle) + $v['s2']['yr'] * sin($angle);
1103
+        $v['s2']['y'] = -$v['s2']['xr'] * sin($angle) + $v['s2']['yr'] * cos($angle);
1104
+        $v['s2']['a1'] = atan2($v['y1'] - $v['s2']['y'], $v['x1'] - $v['s2']['x']);
1105
+        $v['s2']['a2'] = atan2($v['y2'] - $v['s2']['y'], $v['x2'] - $v['s2']['x']);
1106
+        if ($v['s2']['a1'] > $v['s2']['a2']) $v['s2']['a1'] -= 2 * M_PI;
1107 1107
 
1108 1108
         if (!$l) {
1109 1109
             if ($s) {
@@ -1145,20 +1145,20 @@  discard block
 block discarded – undo
1145 1145
      * @return boolean
1146 1146
      * @access public
1147 1147
      */
1148
-    public function ptTransform(&$x,  &$y, $trans=true)
1148
+    public function ptTransform(&$x, &$y, $trans = true)
1149 1149
     {
1150 1150
         // load the last Transfomation Matrix
1151 1151
         $nb = count($this->_transf);
1152
-        if ($nb)    $m = $this->_transf[$nb-1];
1153
-        else        $m = array(1,0,0,1,0,0);
1152
+        if ($nb)    $m = $this->_transf[$nb - 1];
1153
+        else        $m = array(1, 0, 0, 1, 0, 0);
1154 1154
 
1155 1155
         // apply the Transformation Matrix
1156
-        list($x,$y) = array(($x*$m[0]+$y*$m[2]+$m[4]),($x*$m[1]+$y*$m[3]+$m[5]));
1156
+        list($x, $y) = array(($x * $m[0] + $y * $m[2] + $m[4]), ($x * $m[1] + $y * $m[3] + $m[5]));
1157 1157
 
1158 1158
         // if true => convert into PDF unit
1159 1159
         if ($trans) {
1160
-            $x = $x*$this->k;
1161
-            $y = ($this->h-$y)*$this->k;
1160
+            $x = $x * $this->k;
1161
+            $y = ($this->h - $y) * $this->k;
1162 1162
         }
1163 1163
 
1164 1164
         return true;
@@ -1174,20 +1174,20 @@  discard block
 block discarded – undo
1174 1174
     {
1175 1175
         // get the last Transformation Matrix
1176 1176
         $nb = count($this->_transf);
1177
-        if ($nb)    $m = $this->_transf[$nb-1];
1178
-        else        $m = array(1,0,0,1,0,0);
1177
+        if ($nb)    $m = $this->_transf[$nb - 1];
1178
+        else        $m = array(1, 0, 0, 1, 0, 0);
1179 1179
 
1180 1180
         // if no transform, get the Identity Matrix
1181
-        if (!$n) $n = array(1,0,0,1,0,0);
1181
+        if (!$n) $n = array(1, 0, 0, 1, 0, 0);
1182 1182
 
1183 1183
         // create the new Transformation Matrix
1184 1184
         $this->_transf[] = array(
1185
-            $m[0]*$n[0]+$m[2]*$n[1],
1186
-            $m[1]*$n[0]+$m[3]*$n[1],
1187
-            $m[0]*$n[2]+$m[2]*$n[3],
1188
-            $m[1]*$n[2]+$m[3]*$n[3],
1189
-            $m[0]*$n[4]+$m[2]*$n[5]+$m[4],
1190
-            $m[1]*$n[4]+$m[3]*$n[5]+$m[5]
1185
+            $m[0] * $n[0] + $m[2] * $n[1],
1186
+            $m[1] * $n[0] + $m[3] * $n[1],
1187
+            $m[0] * $n[2] + $m[2] * $n[3],
1188
+            $m[1] * $n[2] + $m[3] * $n[3],
1189
+            $m[0] * $n[4] + $m[2] * $n[5] + $m[4],
1190
+            $m[1] * $n[4] + $m[3] * $n[5] + $m[5]
1191 1191
         );
1192 1192
     }
1193 1193
 
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
         $this->write1DBarcode($code, $type, $x, $y, $w, $h, '', $style, 'N');
1229 1229
 
1230 1230
         // it Label => add the FontSize to the height
1231
-        if ($labelFontsize) $h+= ($labelFontsize);
1231
+        if ($labelFontsize) $h += ($labelFontsize);
1232 1232
 
1233 1233
         // return the size of the barcode
1234 1234
         return array($w, $h);
@@ -1269,48 +1269,48 @@  discard block
 block discarded – undo
1269 1269
         $this->Ln(10);
1270 1270
 
1271 1271
         // get the number of bookmarks
1272
-        $size=sizeof($this->outlines);
1272
+        $size = sizeof($this->outlines);
1273 1273
 
1274 1274
         // get the size of the "P. xx" cell
1275
-        $pageCellSize=$this->GetStringWidth('p. '.$this->outlines[$size-1]['p'])+2;
1275
+        $pageCellSize = $this->GetStringWidth('p. ' . $this->outlines[$size - 1]['p']) + 2;
1276 1276
 
1277 1277
         // Foreach bookmark
1278
-        for ($i=0;$i<$size;$i++) {
1278
+        for ($i = 0; $i < $size; $i++) {
1279 1279
             // if we need a new page => add a new page
1280
-            if ($this->getY()+$this->FontSize>=($this->h - $this->bMargin)) {
1280
+            if ($this->getY() + $this->FontSize >= ($this->h - $this->bMargin)) {
1281 1281
                 $obj->_INDEX_NewPage($page);
1282 1282
                 $this->SetFont($fontName, '', $sizeBookmark);
1283 1283
             }
1284 1284
 
1285 1285
             // Offset of the current level
1286
-            $level=$this->outlines[$i]['l'];
1287
-            if($level>0) $this->Cell($level*8);
1286
+            $level = $this->outlines[$i]['l'];
1287
+            if ($level > 0) $this->Cell($level * 8);
1288 1288
 
1289 1289
             // Caption (cut to fit on the width page)
1290
-            $str=$this->outlines[$i]['t'];
1291
-            $strsize=$this->GetStringWidth($str);
1292
-            $availableSize=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-4;
1293
-            while ($strsize>=$availableSize) {
1294
-                $str=substr($str, 0, -1);
1295
-                $strsize=$this->GetStringWidth($str);
1290
+            $str = $this->outlines[$i]['t'];
1291
+            $strsize = $this->GetStringWidth($str);
1292
+            $availableSize = $this->w - $this->lMargin - $this->rMargin - $pageCellSize - ($level * 8) - 4;
1293
+            while ($strsize >= $availableSize) {
1294
+                $str = substr($str, 0, -1);
1295
+                $strsize = $this->GetStringWidth($str);
1296 1296
             }
1297 1297
 
1298 1298
             // if we want to display the page nmber
1299 1299
             if ($displayPage) {
1300 1300
                 // display the Bookmark Caption
1301
-                $this->Cell($strsize+2, $this->FontSize+2, $str);
1301
+                $this->Cell($strsize + 2, $this->FontSize + 2, $str);
1302 1302
 
1303 1303
                 //Filling dots
1304
-                $w=$this->w-$this->lMargin-$this->rMargin-$pageCellSize-($level*8)-($strsize+2);
1305
-                $nb=$w/$this->GetStringWidth('.');
1306
-                $dots=str_repeat('.', $nb);
1307
-                $this->Cell($w, $this->FontSize+2, $dots, 0, 0, 'R');
1304
+                $w = $this->w - $this->lMargin - $this->rMargin - $pageCellSize - ($level * 8) - ($strsize + 2);
1305
+                $nb = $w / $this->GetStringWidth('.');
1306
+                $dots = str_repeat('.', $nb);
1307
+                $this->Cell($w, $this->FontSize + 2, $dots, 0, 0, 'R');
1308 1308
 
1309 1309
                 //Page number
1310
-                $this->Cell($pageCellSize, $this->FontSize+2, 'p. '.$this->outlines[$i]['p'], 0, 1, 'R');
1310
+                $this->Cell($pageCellSize, $this->FontSize + 2, 'p. ' . $this->outlines[$i]['p'], 0, 1, 'R');
1311 1311
             } else {
1312 1312
                 // display the Bookmark Caption
1313
-                $this->Cell($strsize+2, $this->FontSize+2, $str, 0, 1);
1313
+                $this->Cell($strsize + 2, $this->FontSize + 2, $str, 0, 1);
1314 1314
             }
1315 1315
         }
1316 1316
     }
@@ -1324,11 +1324,11 @@  discard block
 block discarded – undo
1324 1324
      */
1325 1325
     public function getMyAliasNbPages()
1326 1326
     {
1327
-        if ($this->_myLastPageGroupNb==0) {
1327
+        if ($this->_myLastPageGroupNb == 0) {
1328 1328
             return $this->getAliasNbPages();
1329 1329
         } else {
1330 1330
             $old = $this->currpagegroup;
1331
-            $this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
1331
+            $this->currpagegroup = '{nb' . $this->_myLastPageGroupNb . '}';
1332 1332
             $new = $this->getPageGroupAlias();
1333 1333
             $this->currpagegroup = $old;
1334 1334
 
@@ -1343,16 +1343,16 @@  discard block
 block discarded – undo
1343 1343
      * @param  integer $page
1344 1344
      * @return integer;
1345 1345
      */
1346
-    public function getMyNumPage($page=null)
1346
+    public function getMyNumPage($page = null)
1347 1347
     {
1348
-        if ($page===null) {
1348
+        if ($page === null) {
1349 1349
             $page = $this->page;
1350 1350
         }
1351 1351
 
1352
-        if ($this->_myLastPageGroupNb==0) {
1352
+        if ($this->_myLastPageGroupNb == 0) {
1353 1353
             return $page;
1354 1354
         } else {
1355
-            return $page-$this->_myLastPageGroup;
1355
+            return $page - $this->_myLastPageGroup;
1356 1356
         }
1357 1357
     }
1358 1358
 
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
      */
1366 1366
     public function myStartPageGroup()
1367 1367
     {
1368
-        $this->_myLastPageGroup = $this->page-1;
1368
+        $this->_myLastPageGroup = $this->page - 1;
1369 1369
         $this->_myLastPageGroupNb++;
1370 1370
     }
1371 1371
 
Please login to merge, or discard this patch.
Braces   +73 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - myPdf class
4 6
  *
@@ -552,8 +554,12 @@  discard block
 block discarded – undo
552 554
     public function setRotation($angle, $xC=null, $yC=null)
553 555
     {
554 556
         // if no center, rotate around the current posiition
555
-        if($xC === null) $xC=$this->x;
556
-        if($yC === null) $yC=$this->y;
557
+        if($xC === null) {
558
+        	$xC=$this->x;
559
+        }
560
+        if($yC === null) {
561
+        	$yC=$this->y;
562
+        }
557 563
 
558 564
         // prepare the coordinate
559 565
         $yC=($this->h-$yC)*$this->k;
@@ -595,8 +601,9 @@  discard block
 block discarded – undo
595 601
      */
596 602
     public function SetY($y, $resetx=true, $rtloff=false)
597 603
     {
598
-        if ($resetx)
599
-            $this->x=$this->lMargin;
604
+        if ($resetx) {
605
+                    $this->x=$this->lMargin;
606
+        }
600 607
 
601 608
         $this->y=$y;
602 609
     }
@@ -713,9 +720,13 @@  discard block
 block discarded – undo
713 720
         $y4=$y+$h;
714 721
 
715 722
         // get the Closing operator from the PDF Style
716
-        if($style=='F') $op='f';
717
-        elseif($style=='FD' || $style=='DF') $op='B';
718
-        else $op='S';
723
+        if($style=='F') {
724
+        	$op='f';
725
+        } elseif($style=='FD' || $style=='DF') {
726
+        	$op='B';
727
+        } else {
728
+        	$op='S';
729
+        }
719 730
 
720 731
         // drawing
721 732
         $this->_Point($x1, $y1, true);
@@ -759,9 +770,13 @@  discard block
 block discarded – undo
759 770
     public function svgEllipse($x0, $y0, $rx, $ry, $style)
760 771
     {
761 772
         // get the Closing operator from the PDF Style
762
-        if($style=='F') $op='f';
763
-        elseif($style=='FD' || $style=='DF') $op='B';
764
-        else $op='S';
773
+        if($style=='F') {
774
+        	$op='f';
775
+        } elseif($style=='FD' || $style=='DF') {
776
+        	$op='B';
777
+        } else {
778
+        	$op='S';
779
+        }
765 780
 
766 781
         // drawing
767 782
         $this->_Arc($x0, $y0, $rx, $ry, 0, 2*M_PI, true, true, true);
@@ -778,9 +793,13 @@  discard block
 block discarded – undo
778 793
     public function svgPolygone($actions, $style)
779 794
     {
780 795
         // get the Closing operator from the PDF Style
781
-        if($style=='F') $op='f';
782
-        elseif($style=='FD' || $style=='DF') $op='B';
783
-        else $op='S';
796
+        if($style=='F') {
797
+        	$op='f';
798
+        } elseif($style=='FD' || $style=='DF') {
799
+        	$op='B';
800
+        } else {
801
+        	$op='S';
802
+        }
784 803
 
785 804
         // To save the First action and the last point
786 805
         $first = array('', 0, 0);
@@ -919,7 +938,9 @@  discard block
 block discarded – undo
919 938
      */
920 939
     protected function _Point($x, $y, $trans = false)
921 940
     {
922
-        if ($trans) $this->ptTransform($x, $y);
941
+        if ($trans) {
942
+        	$this->ptTransform($x, $y);
943
+        }
923 944
 
924 945
         $this->_out(sprintf('%.2F %.2F m', $x, $y));
925 946
     }
@@ -934,7 +955,9 @@  discard block
 block discarded – undo
934 955
      */
935 956
     protected function _Line($x, $y, $trans = false)
936 957
     {
937
-        if ($trans) $this->ptTransform($x, $y);
958
+        if ($trans) {
959
+        	$this->ptTransform($x, $y);
960
+        }
938 961
 
939 962
         $this->_out(sprintf('%.2F %.2F l', $x, $y));
940 963
     }
@@ -987,7 +1010,9 @@  discard block
 block discarded – undo
987 1010
         $trans=false)
988 1011
     {
989 1012
         // if we want the no trigo direction : add 2PI to the begin angle, to invert the direction
990
-        if (!$direction) $angleBegin+= M_PI*2.;
1013
+        if (!$direction) {
1014
+        	$angleBegin+= M_PI*2.;
1015
+        }
991 1016
 
992 1017
         // cut in segment to convert in berize curv
993 1018
         $dt = ($angleEnd - $angleBegin)/self::ARC_NB_SEGMENT;
@@ -1004,7 +1029,9 @@  discard block
 block discarded – undo
1004 1029
         $d0 = $ry * cos($t1);
1005 1030
 
1006 1031
         // if drawFirst => draw the first point
1007
-        if ($drawFirst) $this->_Point($a0, $b0, $trans);
1032
+        if ($drawFirst) {
1033
+        	$this->_Point($a0, $b0, $trans);
1034
+        }
1008 1035
 
1009 1036
         // foreach segment
1010 1037
         for ($i = 1; $i <= self::ARC_NB_SEGMENT; $i++) {
@@ -1091,7 +1118,9 @@  discard block
 block discarded – undo
1091 1118
         $v['s1']['y'] =-$v['s1']['xr']*sin($angle)+$v['s1']['yr']*cos($angle);
1092 1119
         $v['s1']['a1'] = atan2($v['y1']-$v['s1']['y'], $v['x1']-$v['s1']['x']);
1093 1120
         $v['s1']['a2'] = atan2($v['y2']-$v['s1']['y'], $v['x2']-$v['s1']['x']);
1094
-        if ($v['s1']['a1']>$v['s1']['a2']) $v['s1']['a1']-=2*M_PI;
1121
+        if ($v['s1']['a1']>$v['s1']['a2']) {
1122
+        	$v['s1']['a1']-=2*M_PI;
1123
+        }
1095 1124
 
1096 1125
         $v['s2'] = array();
1097 1126
         $v['s2']['t'] = -$v['s1']['t'];
@@ -1103,7 +1132,9 @@  discard block
 block discarded – undo
1103 1132
         $v['s2']['y'] =-$v['s2']['xr']*sin($angle)+$v['s2']['yr']*cos($angle);
1104 1133
         $v['s2']['a1'] = atan2($v['y1']-$v['s2']['y'], $v['x1']-$v['s2']['x']);
1105 1134
         $v['s2']['a2'] = atan2($v['y2']-$v['s2']['y'], $v['x2']-$v['s2']['x']);
1106
-        if ($v['s2']['a1']>$v['s2']['a2']) $v['s2']['a1']-=2*M_PI;
1135
+        if ($v['s2']['a1']>$v['s2']['a2']) {
1136
+        	$v['s2']['a1']-=2*M_PI;
1137
+        }
1107 1138
 
1108 1139
         if (!$l) {
1109 1140
             if ($s) {
@@ -1149,8 +1180,11 @@  discard block
 block discarded – undo
1149 1180
     {
1150 1181
         // load the last Transfomation Matrix
1151 1182
         $nb = count($this->_transf);
1152
-        if ($nb)    $m = $this->_transf[$nb-1];
1153
-        else        $m = array(1,0,0,1,0,0);
1183
+        if ($nb) {
1184
+        	$m = $this->_transf[$nb-1];
1185
+        } else {
1186
+        	$m = array(1,0,0,1,0,0);
1187
+        }
1154 1188
 
1155 1189
         // apply the Transformation Matrix
1156 1190
         list($x,$y) = array(($x*$m[0]+$y*$m[2]+$m[4]),($x*$m[1]+$y*$m[3]+$m[5]));
@@ -1174,11 +1208,16 @@  discard block
 block discarded – undo
1174 1208
     {
1175 1209
         // get the last Transformation Matrix
1176 1210
         $nb = count($this->_transf);
1177
-        if ($nb)    $m = $this->_transf[$nb-1];
1178
-        else        $m = array(1,0,0,1,0,0);
1211
+        if ($nb) {
1212
+        	$m = $this->_transf[$nb-1];
1213
+        } else {
1214
+        	$m = array(1,0,0,1,0,0);
1215
+        }
1179 1216
 
1180 1217
         // if no transform, get the Identity Matrix
1181
-        if (!$n) $n = array(1,0,0,1,0,0);
1218
+        if (!$n) {
1219
+        	$n = array(1,0,0,1,0,0);
1220
+        }
1182 1221
 
1183 1222
         // create the new Transformation Matrix
1184 1223
         $this->_transf[] = array(
@@ -1228,7 +1267,9 @@  discard block
 block discarded – undo
1228 1267
         $this->write1DBarcode($code, $type, $x, $y, $w, $h, '', $style, 'N');
1229 1268
 
1230 1269
         // it Label => add the FontSize to the height
1231
-        if ($labelFontsize) $h+= ($labelFontsize);
1270
+        if ($labelFontsize) {
1271
+        	$h+= ($labelFontsize);
1272
+        }
1232 1273
 
1233 1274
         // return the size of the barcode
1234 1275
         return array($w, $h);
@@ -1258,7 +1299,9 @@  discard block
 block discarded – undo
1258 1299
         $fontName = 'helvetica')
1259 1300
     {
1260 1301
         // bookmark the Title if wanted
1261
-        if ($bookmarkTitle) $this->Bookmark($titre, 0, -1);
1302
+        if ($bookmarkTitle) {
1303
+        	$this->Bookmark($titre, 0, -1);
1304
+        }
1262 1305
 
1263 1306
         // display the Title with the good Font size
1264 1307
         $this->SetFont($fontName, '', $sizeTitle);
@@ -1284,7 +1327,9 @@  discard block
 block discarded – undo
1284 1327
 
1285 1328
             // Offset of the current level
1286 1329
             $level=$this->outlines[$i]['l'];
1287
-            if($level>0) $this->Cell($level*8);
1330
+            if($level>0) {
1331
+            	$this->Cell($level*8);
1332
+            }
1288 1333
 
1289 1334
             // Caption (cut to fit on the width page)
1290 1335
             $str=$this->outlines[$i]['t'];
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/parsingCss.class.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,7 @@  discard block
 block discarded – undo
30 30
      * Constructor
31 31
      *
32 32
      * @param  &HTML2PDF_myPdf reference to the PDF $object
33
+     * @param HTML2PDF_myPdf $pdf
33 34
      * @access public
34 35
      */
35 36
     public function __construct(&$pdf)
@@ -75,6 +76,7 @@  discard block
 block discarded – undo
75 76
     * define the Default Font to use, if the font does not exist, or if no font asked
76 77
     *
77 78
     * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
79
+    * @param string $default
78 80
     * @return string  old default font-family
79 81
     * @access public
80 82
     */
@@ -473,6 +475,7 @@  discard block
 block discarded – undo
473 475
      * @access public
474 476
      * @param  string   tag name
475 477
      * @param  array    styles
478
+     * @param string $tagName
476 479
      */
477 480
     public function getSvgStyle($tagName, &$param)
478 481
     {
@@ -1661,7 +1664,7 @@  discard block
 block discarded – undo
1661 1664
      * read a css content
1662 1665
      *
1663 1666
      * @access protected
1664
-     * @param  &string $code
1667
+     * @param  string $code
1665 1668
      */
1666 1669
     protected function _analyseStyle(&$code)
1667 1670
     {
@@ -1725,6 +1728,7 @@  discard block
 block discarded – undo
1725 1728
      *
1726 1729
      * @access public
1727 1730
      * @param  string   &$html
1731
+     * @param string $html
1728 1732
      */
1729 1733
     public function readStyle(&$html)
1730 1734
     {
Please login to merge, or discard this patch.
Indentation   +1797 added lines, -1797 removed lines patch added patch discarded remove patch
@@ -11,1802 +11,1802 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingCss
13 13
 {
14
-    /**
15
-     * reference to the pdf object
16
-     * @var TCPDF
17
-     */
18
-    protected $_pdf         = null;
19
-
20
-    protected $_htmlColor   = array(); // list of the HTML colors
21
-    protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
-    protected $_defaultFont = null;    // default font to use if the asked font does not exist
23
-
24
-    public    $value        = array(); // current values
25
-    public    $css          = array(); // css values
26
-    public    $cssKeys      = array(); // css key, for the execution order
27
-    public    $table        = array(); // level history
28
-
29
-    /**
30
-     * Constructor
31
-     *
32
-     * @param  &HTML2PDF_myPdf reference to the PDF $object
33
-     * @access public
34
-     */
35
-    public function __construct(&$pdf)
36
-    {
37
-        $this->_init();
38
-        $this->setPdfParent($pdf);
39
-    }
40
-
41
-    /**
42
-     * Set the HTML2PDF parent object
43
-     *
44
-     * @param  &HTML2PDF reference to the HTML2PDF parent $object
45
-     * @access public
46
-     */
47
-    public function setPdfParent(&$pdf)
48
-    {
49
-        $this->_pdf = &$pdf;
50
-    }
51
-
52
-    /**
53
-     * Inform that we want only "test-align:left" because we are in a sub HTML
54
-     *
55
-     * @access public
56
-     */
57
-    public function setOnlyLeft()
58
-    {
59
-        $this->value['text-align'] = 'left';
60
-        $this->_onlyLeft = true;
61
-    }
62
-
63
-    /**
64
-     * Get the vales of the parent, if exist
65
-     *
66
-     * @return array CSS values
67
-     * @access public
68
-     */
69
-    public function getOldValues()
70
-    {
71
-        return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
72
-    }
73
-
74
-    /**
75
-    * define the Default Font to use, if the font does not exist, or if no font asked
76
-    *
77
-    * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
78
-    * @return string  old default font-family
79
-    * @access public
80
-    */
81
-    public function setDefaultFont($default = null)
82
-    {
83
-        $old = $this->_defaultFont;
84
-        $this->_defaultFont = $default;
85
-        if ($default) $this->value['font-family'] = $default;
86
-        return $old;
87
-    }
88
-
89
-     /**
90
-     * Init the object
91
-     *
92
-     * @access protected
93
-     */
94
-    protected function _init()
95
-    {
96
-        // get the Web Colors from TCPDF
97
-        require(K_PATH_MAIN.'htmlcolors.php');
98
-        $this->_htmlColor = $webcolor;
99
-
100
-        // init the Style
101
-        $this->table = array();
102
-        $this->value = array();
103
-        $this->initStyle();
104
-
105
-        // Init the styles without legacy
106
-        $this->resetStyle();
107
-    }
108
-
109
-    /**
110
-     * Init the CSS Style
111
-     *
112
-     * @access public
113
-     */
114
-    public function initStyle()
115
-    {
116
-        $this->value['id_tag']       = 'body';        // tag name
117
-        $this->value['id_name']          = null;         // tag - attribute name
118
-        $this->value['id_id']            = null;         // tag - attribute id
119
-        $this->value['id_class']         = null;         // tag - attribute class
120
-        $this->value['id_lst']           = array('*');   // tag - list of legacy
121
-        $this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
-        $this->value['mini-decal']       = 0;            // specific position report for sup, sub
123
-        $this->value['font-family']      = 'Arial';
124
-        $this->value['font-bold']        = false;
125
-        $this->value['font-italic']      = false;
126
-        $this->value['font-underline']   = false;
127
-        $this->value['font-overline']    = false;
128
-        $this->value['font-linethrough'] = false;
129
-        $this->value['text-transform']   = 'none';
130
-        $this->value['font-size']        = $this->convertToMM('10pt');
131
-        $this->value['text-indent']      = 0;
132
-        $this->value['text-align']       = 'left';
133
-        $this->value['vertical-align']   = 'middle';
134
-        $this->value['line-height']      = 'normal';
135
-
136
-        $this->value['position']         = null;
137
-        $this->value['x']                = null;
138
-        $this->value['y']                = null;
139
-        $this->value['width']            = 0;
140
-        $this->value['height']           = 0;
141
-        $this->value['top']              = null;
142
-        $this->value['right']            = null;
143
-        $this->value['bottom']           = null;
144
-        $this->value['left']             = null;
145
-        $this->value['float']            = null;
146
-        $this->value['display']          = null;
147
-        $this->value['rotate']           = null;
148
-        $this->value['overflow']         = 'visible';
149
-
150
-        $this->value['color']            = array(0, 0, 0);
151
-        $this->value['background']       = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
152
-        $this->value['border']           = array();
153
-        $this->value['padding']          = array();
154
-        $this->value['margin']           = array();
155
-        $this->value['margin-auto']      = false;
156
-
157
-        $this->value['list-style-type']  = '';
158
-        $this->value['list-style-image'] = '';
159
-
160
-        $this->value['xc'] = null;
161
-        $this->value['yc'] = null;
162
-    }
163
-
164
-    /**
165
-     * Init the CSS Style without legacy
166
-     *
167
-     * @param  string  tag name
168
-     * @access public
169
-     */
170
-    public function resetStyle($tagName = '')
171
-    {
172
-        // prepare somme values
173
-        $border = $this->readBorder('solid 1px #000000');
174
-        $units = array(
175
-            '1px' => $this->convertToMM('1px'),
176
-            '5px' => $this->convertToMM('5px'),
177
-        );
178
-
179
-
180
-        // prepare the Collapse attribute
181
-        $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
-        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
183
-
184
-        // set the global css values
185
-        $this->value['position']   = null;
186
-        $this->value['x']          = null;
187
-        $this->value['y']          = null;
188
-        $this->value['width']      = 0;
189
-        $this->value['height']     = 0;
190
-        $this->value['top']        = null;
191
-        $this->value['right']      = null;
192
-        $this->value['bottom']     = null;
193
-        $this->value['left']       = null;
194
-        $this->value['float']      = null;
195
-        $this->value['display']    = null;
196
-        $this->value['rotate']     = null;
197
-        $this->value['overflow']   = 'visible';
198
-        $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
199
-        $this->value['border']     = array(
200
-            't' => $this->readBorder('none'),
201
-            'r' => $this->readBorder('none'),
202
-            'b' => $this->readBorder('none'),
203
-            'l' => $this->readBorder('none'),
204
-            'radius' => array(
205
-                'tl' => array(0, 0),
206
-                'tr' => array(0, 0),
207
-                'br' => array(0, 0),
208
-                'bl' => array(0, 0)
209
-            ),
210
-            'collapse' => $collapse,
211
-        );
212
-
213
-        // specific values for some tags
214
-        if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
-            $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
216
-        }
217
-
218
-        if (in_array($tagName, array('input', 'select', 'textarea'))) {
219
-            $this->value['border']['t'] = null;
220
-            $this->value['border']['r'] = null;
221
-            $this->value['border']['b'] = null;
222
-            $this->value['border']['l'] = null;
223
-        }
224
-
225
-        if ($tagName=='p') {
226
-            $this->value['margin']['t'] = null;
227
-            $this->value['margin']['b'] = null;
228
-        }
229
-        if ($tagName=='blockquote') {
230
-            $this->value['margin']['t'] = 3;
231
-            $this->value['margin']['r'] = 3;
232
-            $this->value['margin']['b'] = 3;
233
-            $this->value['margin']['l'] = 6;
234
-        }
235
-        $this->value['margin-auto'] = false;
236
-
237
-        if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) {
238
-            $this->value['vertical-align'] = 'top';
239
-        }
240
-
241
-        if (in_array($tagName, array('fieldset', 'legend'))) {
242
-            $this->value['border'] = array(
243
-                't' => $border,
244
-                'r' => $border,
245
-                'b' => $border,
246
-                'l' => $border,
247
-                'radius' => array(
248
-                    'tl' => array($units['5px'], $units['5px']),
249
-                    'tr' => array($units['5px'], $units['5px']),
250
-                    'br' => array($units['5px'], $units['5px']),
251
-                    'bl' => array($units['5px'], $units['5px'])
252
-                ),
253
-                'collapse' => false,
254
-            );
255
-        }
256
-
257
-        if (in_array($tagName, array('ul', 'li'))) {
258
-            $this->value['list-style-type']  = '';
259
-            $this->value['list-style-image'] = '';
260
-        }
261
-
262
-        if (!in_array($tagName, array('tr', 'td'))) {
263
-            $this->value['padding'] = array(
264
-                't' => 0,
265
-                'r' => 0,
266
-                'b' => 0,
267
-                'l' => 0
268
-            );
269
-        } else {
270
-            $this->value['padding'] = array(
271
-                't' => $units['1px'],
272
-                'r' => $units['1px'],
273
-                'b' => $units['1px'],
274
-                'l' => $units['1px']
275
-            );
276
-        }
277
-
278
-        if ($tagName=='hr') {
279
-            $this->value['border'] = array(
280
-                't' => $border,
281
-                'r' => $border,
282
-                'b' => $border,
283
-                'l' => $border,
284
-                'radius' => array(
285
-                    'tl' => array(0, 0),
286
-                    'tr' => array(0, 0),
287
-                    'br' => array(0, 0),
288
-                    'bl' => array(0, 0)
289
-                ),
290
-                'collapse' => false,
291
-            );
292
-            $this->convertBackground('#FFFFFF', $this->value['background']);
293
-        }
294
-
295
-        $this->value['xc'] = null;
296
-        $this->value['yc'] = null;
297
-    }
298
-
299
-    /**
300
-     * Init the PDF Font
301
-     *
302
-     * @access public
303
-     */
304
-    public function fontSet()
305
-    {
306
-        $family = strtolower($this->value['font-family']);
307
-
308
-        $b = ($this->value['font-bold']        ? 'B' : '');
309
-        $i = ($this->value['font-italic']      ? 'I' : '');
310
-        $u = ($this->value['font-underline']   ? 'U' : '');
311
-        $d = ($this->value['font-linethrough'] ? 'D' : '');
312
-        $o = ($this->value['font-overline']    ? 'O' : '');
313
-
314
-        // font style
315
-        $style = $b.$i;
316
-
317
-        if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
322
-
323
-            $fontkey = $family.$style;
324
-            if (!$this->_pdf->isLoadedFont($fontkey))
325
-                $family = $this->_defaultFont;
326
-        }
327
-
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
332
-
333
-        // complete style
334
-        $style.= $u.$d.$o;
335
-
336
-        // size : mm => pt
337
-        $size = $this->value['font-size'];
338
-        $size = 72 * $size / 25.4;
339
-
340
-        // apply the font
341
-        $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342
-        $this->_pdf->setTextColorArray($this->value['color']);
343
-        if ($this->value['background']['color'])
344
-            $this->_pdf->setFillColorArray($this->value['background']['color']);
345
-        else
346
-            $this->_pdf->setFillColor(255);
347
-    }
348
-
349
-     /**
350
-     * add a level in the CSS history
351
-     *
352
-     * @access public
353
-     */
354
-    public function save()
355
-    {
356
-        array_push($this->table, $this->value);
357
-    }
358
-
359
-     /**
360
-     * remove a level in the CSS history
361
-     *
362
-     * @access public
363
-     */
364
-    public function load()
365
-    {
366
-        if (count($this->table)) {
367
-            $this->value = array_pop($this->table);
368
-        }
369
-    }
370
-
371
-     /**
372
-     * restore the Y positiony (used after a span)
373
-     *
374
-     * @access public
375
-     */
376
-    public function restorePosition()
377
-    {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379
-    }
380
-
381
-     /**
382
-     * set the New position for the current Tag
383
-     *
384
-     * @access public
385
-     */
386
-    public function setPosition()
387
-    {
388
-        // get the current position
389
-        $currentX = $this->_pdf->getX();
390
-        $currentY = $this->_pdf->getY();
391
-
392
-        // save it
393
-        $this->value['xc'] = $currentX;
394
-        $this->value['yc'] = $currentY;
395
-
396
-        if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
-            if ($this->value['right']!==null) {
398
-                $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
400
-            } else {
401
-                $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
403
-            }
404
-
405
-            if ($this->value['bottom']!==null) {
406
-                $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
408
-            } else {
409
-                $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
411
-            }
412
-
413
-            if ($this->value['position']=='relative') {
414
-                $this->value['x'] = $currentX + $x;
415
-                $this->value['y'] = $currentY + $y;
416
-            } else {
417
-                $this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
-                $this->value['y'] = $this->_getLastAbsoluteY()+$y;
419
-            }
420
-        } else {
421
-            $this->value['x'] = $currentX;
422
-            $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
425
-        }
426
-
427
-        // save the new position
428
-        $this->_pdf->setXY($this->value['x'], $this->value['y']);
429
-    }
430
-
431
-     /**
432
-     * Analise the CSS style to convert it into Form style
433
-     *
434
-     * @access public
435
-     * @param  array    styles
436
-     */
437
-    public function getFormStyle()
438
-    {
439
-        $prop = array();
440
-
441
-        $prop['alignment'] = $this->value['text-align'];
442
-
443
-        if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) {
444
-            $prop['fillColor'] = $this->value['background']['color'];
445
-        }
446
-
447
-        if (isset($this->value['border']['t']['color'])) {
448
-            $prop['strokeColor'] = $this->value['border']['t']['color'];
449
-        }
450
-
451
-        if (isset($this->value['border']['t']['width'])) {
452
-            $prop['lineWidth'] = $this->value['border']['t']['width'];
453
-        }
454
-
455
-        if (isset($this->value['border']['t']['type'])) {
456
-            $prop['borderStyle'] = $this->value['border']['t']['type'];
457
-        }
458
-
459
-        if (!empty($this->value['color'])) {
460
-            $prop['textColor'] = $this->value['color'];
461
-        }
462
-
463
-        if (!empty($this->value['font-size'])) {
464
-            $prop['textSize'] = $this->value['font-size'];
465
-        }
466
-
467
-        return $prop;
468
-    }
469
-
470
-     /**
471
-     * Analise the CSS style to convert it into SVG style
472
-     *
473
-     * @access public
474
-     * @param  string   tag name
475
-     * @param  array    styles
476
-     */
477
-    public function getSvgStyle($tagName, &$param)
478
-    {
479
-        // prepare
480
-        $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
-        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483
-
484
-        // read the class attribute
485
-        $class = array();
486
-        $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
487
-        $tmp = explode(' ', $tmp);
488
-        foreach ($tmp as $k => $v) {
489
-            $v = trim($v);
490
-            if ($v) $class[] = $v;
491
-        }
492
-
493
-        // identify the tag, and the direct styles
494
-        $this->value['id_tag'] = $tagName;
495
-        $this->value['id_name']   = $name;
496
-        $this->value['id_id']     = $id;
497
-        $this->value['id_class']  = $class;
498
-        $this->value['id_lst']    = array();
499
-        $this->value['id_lst'][] = '*';
500
-        $this->value['id_lst'][] = $tagName;
501
-        if (!isset($this->value['svg'])) {
502
-            $this->value['svg'] = array(
503
-                'stroke'         => null,
504
-                'stroke-width'   => $this->convertToMM('1pt'),
505
-                'fill'           => null,
506
-                'fill-opacity'   => null,
507
-            );
508
-        }
509
-
510
-        if (count($class)) {
511
-            foreach ($class as $v) {
512
-                $this->value['id_lst'][] = '*.'.$v;
513
-                $this->value['id_lst'][] = '.'.$v;
514
-                $this->value['id_lst'][] = $tagName.'.'.$v;
515
-            }
516
-        }
517
-        if ($id) {
518
-            $this->value['id_lst'][] = '*#'.$id;
519
-            $this->value['id_lst'][] = '#'.$id;
520
-            $this->value['id_lst'][] = $tagName.'#'.$id;
521
-        }
522
-
523
-        // CSS style
524
-        $styles = $this->_getFromCSS();
525
-
526
-        // adding the style from the tag
527
-        $styles = array_merge($styles, $param['style']);
528
-
529
-        if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
-        if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
-        if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
533
-
534
-        return $this->value['svg'];
535
-    }
536
-
537
-    /**
538
-     * analyse the css properties from the HTML parsing
539
-     *
540
-     * @access public
541
-     * @param  string  $tagName
542
-     * @param  array   $param
543
-     * @param  array   $legacy
544
-     */
545
-    public function analyse($tagName, &$param, $legacy = null)
546
-    {
547
-        // prepare the informations
548
-        $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
551
-
552
-        // get the class names to use
553
-        $class = array();
554
-        $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
555
-        $tmp = explode(' ', $tmp);
556
-        foreach ($tmp as $k => $v) {
557
-            $v = trim($v);
558
-            if ($v) $class[] = $v;
559
-        }
560
-
561
-        // prepare the values, and the list of css tags to identify
562
-        $this->value['id_tag']   = $tagName;
563
-        $this->value['id_name']  = $name;
564
-        $this->value['id_id']    = $id;
565
-        $this->value['id_class'] = $class;
566
-        $this->value['id_lst']   = array();
567
-        $this->value['id_lst'][] = '*';
568
-        $this->value['id_lst'][] = $tagName;
569
-        if (count($class)) {
570
-            foreach ($class as $v) {
571
-                $this->value['id_lst'][] = '*.'.$v;
572
-                $this->value['id_lst'][] = '.'.$v;
573
-                $this->value['id_lst'][] = $tagName.'.'.$v;
574
-            }
575
-        }
576
-        if ($id) {
577
-            $this->value['id_lst'][] = '*#'.$id;
578
-            $this->value['id_lst'][] = '#'.$id;
579
-            $this->value['id_lst'][] = $tagName.'#'.$id;
580
-        }
581
-
582
-        // get the css styles from class
583
-        $styles = $this->_getFromCSS();
584
-
585
-        // merge with the css styles from tag
586
-        $styles = array_merge($styles, $param['style']);
587
-        if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
588
-
589
-        // reset some styles, depending on the tag name
590
-        $this->resetStyle($tagName);
591
-
592
-        // add the legacy values
593
-        if ($legacy) {
594
-            foreach ($legacy as $legacyName => $legacyValue) {
595
-                if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
597
-                        $this->value[$legacyName][$legacy2Name] = $legacy2Value;
598
-                } else {
599
-                    $this->value[$legacyName] = $legacyValue;
600
-                }
601
-            }
602
-        }
603
-
604
-        // some flags
605
-        $correctWidth = false;
606
-        $noWidth = true;
607
-
608
-        // read all the css styles
609
-        foreach ($styles as $nom => $val) {
610
-            switch($nom)
611
-            {
612
-                case 'font-family':
613
-                    $val = explode(',', $val);
614
-                    $val = trim($val[0]);
615
-                    if ($val) $this->value['font-family'] = $val;
616
-                    break;
617
-
618
-                case 'font-weight':
619
-                    $this->value['font-bold'] = ($val=='bold');
620
-                    break;
621
-
622
-                case 'font-style':
623
-                    $this->value['font-italic'] = ($val=='italic');
624
-                    break;
625
-
626
-                case 'text-decoration':
627
-                    $val = explode(' ', $val);
628
-                    $this->value['font-underline']   = (in_array('underline', $val));
629
-                    $this->value['font-overline']    = (in_array('overline', $val));
630
-                    $this->value['font-linethrough'] = (in_array('line-through', $val));
631
-                    break;
632
-
633
-                case 'text-indent':
634
-                    $this->value['text-indent'] = $this->convertToMM($val);
635
-                    break;
636
-
637
-                case 'text-transform':
638
-                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
-                    $this->value['text-transform']  = $val;
640
-                    break;
641
-
642
-                case 'font-size':
643
-                    $val = $this->convertToMM($val, $this->value['font-size']);
644
-                    if ($val) $this->value['font-size'] = $val;
645
-                    break;
646
-
647
-                case 'color':
648
-                    $res = null;
649
-                    $this->value['color'] = $this->convertToColor($val, $res);
650
-                    if ($tagName=='hr') {
651
-                        $this->value['border']['l']['color'] = $this->value['color'];
652
-                        $this->value['border']['t']['color'] = $this->value['color'];
653
-                        $this->value['border']['r']['color'] = $this->value['color'];
654
-                        $this->value['border']['b']['color'] = $this->value['color'];
655
-                    }
656
-                    break;
657
-
658
-                case 'text-align':
659
-                    $val = strtolower($val);
660
-                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
661
-                    $this->value['text-align'] = $val;
662
-                    break;
663
-
664
-                case 'vertical-align':
665
-                    $this->value['vertical-align'] = $val;
666
-                    break;
667
-
668
-                case 'width':
669
-                    $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
671
-                    $noWidth = false;
672
-                    break;
673
-
674
-                case 'height':
675
-                    $this->value['height'] = $this->convertToMM($val, $this->getLastHeight());
676
-                    break;
677
-
678
-                case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
680
-                    $this->value['line-height'] = $val;
681
-                    break;
682
-
683
-                case 'rotate':
684
-                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
686
-                    $this->value['rotate'] = $val;
687
-                    break;
688
-
689
-                case 'overflow':
690
-                    if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
691
-                    $this->value['overflow'] = $val;
692
-                    break;
693
-
694
-                case 'padding':
695
-                    $val = explode(' ', $val);
696
-                    foreach ($val as $k => $v) {
697
-                        $v = trim($v);
698
-                        if ($v!='') {
699
-                            $val[$k] = $v;
700
-                        } else {
701
-                            unset($val[$k]);
702
-                        }
703
-                    }
704
-                    $val = array_values($val);
705
-                    $this->_duplicateBorder($val);
706
-                    $this->value['padding']['t'] = $this->convertToMM($val[0], 0);
707
-                    $this->value['padding']['r'] = $this->convertToMM($val[1], 0);
708
-                    $this->value['padding']['b'] = $this->convertToMM($val[2], 0);
709
-                    $this->value['padding']['l'] = $this->convertToMM($val[3], 0);
710
-                    break;
711
-
712
-                case 'padding-top':
713
-                    $this->value['padding']['t'] = $this->convertToMM($val, 0);
714
-                    break;
715
-
716
-                case 'padding-right':
717
-                    $this->value['padding']['r'] = $this->convertToMM($val, 0);
718
-                    break;
719
-
720
-                case 'padding-bottom':
721
-                    $this->value['padding']['b'] = $this->convertToMM($val, 0);
722
-                    break;
723
-
724
-                case 'padding-left':
725
-                    $this->value['padding']['l'] = $this->convertToMM($val, 0);
726
-                    break;
727
-
728
-                case 'margin':
729
-                    if ($val=='auto') {
730
-                        $this->value['margin-auto'] = true;
731
-                        break;
732
-                    }
733
-                    $val = explode(' ', $val);
734
-                    foreach ($val as $k => $v) {
735
-                        $v = trim($v);
736
-                        if ($v!='') {
737
-                            $val[$k] = $v;
738
-                        } else {
739
-                            unset($val[$k]);
740
-                        }
741
-                    }
742
-                    $val = array_values($val);
743
-                    $this->_duplicateBorder($val);
744
-                    $this->value['margin']['t'] = $this->convertToMM($val[0], 0);
745
-                    $this->value['margin']['r'] = $this->convertToMM($val[1], 0);
746
-                    $this->value['margin']['b'] = $this->convertToMM($val[2], 0);
747
-                    $this->value['margin']['l'] = $this->convertToMM($val[3], 0);
748
-                    break;
749
-
750
-                case 'margin-top':
751
-                    $this->value['margin']['t'] = $this->convertToMM($val, 0);
752
-                    break;
753
-
754
-                case 'margin-right':
755
-                    $this->value['margin']['r'] = $this->convertToMM($val, 0);
756
-                    break;
757
-
758
-                case 'margin-bottom':
759
-                    $this->value['margin']['b'] = $this->convertToMM($val, 0);
760
-                    break;
761
-
762
-                case 'margin-left':
763
-                    $this->value['margin']['l'] = $this->convertToMM($val, 0);
764
-                    break;
765
-
766
-                case 'border':
767
-                    $val = $this->readBorder($val);
768
-                    $this->value['border']['t'] = $val;
769
-                    $this->value['border']['r'] = $val;
770
-                    $this->value['border']['b'] = $val;
771
-                    $this->value['border']['l'] = $val;
772
-                    break;
773
-
774
-                case 'border-style':
775
-                    $val = explode(' ', $val);
776
-                    foreach ($val as $valK => $valV) {
777
-                        if (!in_array($valV, array('solid', 'dotted', 'dashed'))) {
778
-                            $val[$valK] = null;
779
-                        }
780
-                    }
781
-                    $this->_duplicateBorder($val);
782
-                    if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
-                    if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
-                    if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
-                    if ($val[3]) $this->value['border']['l']['type'] = $val[3];
786
-                    break;
787
-
788
-                case 'border-top-style':
789
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
790
-                        $this->value['border']['t']['type'] = $val;
791
-                    }
792
-                    break;
793
-
794
-                case 'border-right-style':
795
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
796
-                        $this->value['border']['r']['type'] = $val;
797
-                    }
798
-                    break;
799
-
800
-                case 'border-bottom-style':
801
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
802
-                        $this->value['border']['b']['type'] = $val;
803
-                    }
804
-                    break;
805
-
806
-                case 'border-left-style':
807
-                    if (in_array($val, array('solid', 'dotted', 'dashed')))
808
-                        $this->value['border']['l']['type'] = $val;
809
-                    break;
810
-
811
-                case 'border-color':
812
-                    $res = false;
813
-                    $val = preg_replace('/,[\s]+/', ',', $val);
814
-                    $val = explode(' ', $val);
815
-                    foreach ($val as $valK => $valV) {
816
-                            $val[$valK] = $this->convertToColor($valV, $res);
817
-                            if (!$res) {
818
-                                $val[$valK] = null;
819
-                            }
820
-                    }
821
-                    $this->_duplicateBorder($val);
822
-                    if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
-                    if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
-                    if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
-                    if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
826
-
827
-                    break;
828
-
829
-                case 'border-top-color':
830
-                    $res = false;
831
-                    $val = $this->convertToColor($val, $res);
832
-                    if ($res) $this->value['border']['t']['color'] = $val;
833
-                    break;
834
-
835
-                case 'border-right-color':
836
-                    $res = false;
837
-                    $val = $this->convertToColor($val, $res);
838
-                    if ($res) $this->value['border']['r']['color'] = $val;
839
-                    break;
840
-
841
-                case 'border-bottom-color':
842
-                    $res = false;
843
-                    $val = $this->convertToColor($val, $res);
844
-                    if ($res) $this->value['border']['b']['color'] = $val;
845
-                    break;
846
-
847
-                case 'border-left-color':
848
-                    $res = false;
849
-                    $val = $this->convertToColor($val, $res);
850
-                    if ($res) $this->value['border']['l']['color'] = $val;
851
-                    break;
852
-
853
-                case 'border-width':
854
-                    $val = explode(' ', $val);
855
-                    foreach ($val as $valK => $valV) {
856
-                            $val[$valK] = $this->convertToMM($valV, 0);
857
-                    }
858
-                    $this->_duplicateBorder($val);
859
-                    if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
-                    if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
-                    if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
-                    if ($val[3]) $this->value['border']['l']['width'] = $val[3];
863
-                    break;
864
-
865
-                case 'border-top-width':
866
-                    $val = $this->convertToMM($val, 0);
867
-                    if ($val) $this->value['border']['t']['width'] = $val;
868
-                    break;
869
-
870
-                case 'border-right-width':
871
-                    $val = $this->convertToMM($val, 0);
872
-                    if ($val) $this->value['border']['r']['width'] = $val;
873
-                    break;
874
-
875
-                case 'border-bottom-width':
876
-                    $val = $this->convertToMM($val, 0);
877
-                    if ($val) $this->value['border']['b']['width'] = $val;
878
-                    break;
879
-
880
-                case 'border-left-width':
881
-                    $val = $this->convertToMM($val, 0);
882
-                    if ($val) $this->value['border']['l']['width'] = $val;
883
-                    break;
884
-
885
-                case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
887
-                    break;
888
-
889
-                case 'border-radius':
890
-                    $val = explode('/', $val);
891
-                    if (count($val)>2) {
892
-                        break;
893
-                    }
894
-                    $valH = $this->convertToRadius(trim($val[0]));
895
-                    if (count($valH)<1 || count($valH)>4) {
896
-                        break;
897
-                    }
898
-                    if (!isset($valH[1])) $valH[1] = $valH[0];
899
-                    if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
-                    if (!isset($valH[3])) $valH[3] = $valH[1];
901
-                    if (isset($val[1])) {
902
-                        $valV = $this->convertToRadius(trim($val[1]));
903
-                        if (count($valV)<1 || count($valV)>4) {
904
-                            break;
905
-                        }
906
-                        if (!isset($valV[1])) $valV[1] = $valV[0];
907
-                        if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
-                        if (!isset($valV[3])) $valV[3] = $valV[1];
909
-                    } else {
910
-                        $valV = $valH;
911
-                    }
912
-                    $this->value['border']['radius'] = array(
913
-                                'tl' => array($valH[0], $valV[0]),
914
-                                'tr' => array($valH[1], $valV[1]),
915
-                                'br' => array($valH[2], $valV[2]),
916
-                                'bl' => array($valH[3], $valV[3])
917
-                            );
918
-                    break;
919
-
920
-                case 'border-top-left-radius':
921
-                    $val = $this->convertToRadius($val);
922
-                    if (count($val)<1 || count($val)>2) {
923
-                        break;
924
-                    }
925
-                    $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
926
-                    break;
927
-
928
-                case 'border-top-right-radius':
929
-                    $val = $this->convertToRadius($val);
930
-                    if (count($val)<1 || count($val)>2) {
931
-                        break;
932
-                    }
933
-                    $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
934
-                    break;
935
-
936
-                case 'border-bottom-right-radius':
937
-                    $val = $this->convertToRadius($val);
938
-                    if (count($val)<1 || count($val)>2) {
939
-                        break;
940
-                    }
941
-                    $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
942
-                    break;
943
-
944
-                case 'border-bottom-left-radius':
945
-                    $val = $this->convertToRadius($val);
946
-                    if (count($val)<1 || count($val)>2) {
947
-                        break;
948
-                    }
949
-                    $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
950
-                    break;
951
-
952
-                case 'border-top':
953
-                    $this->value['border']['t'] = $this->readBorder($val);
954
-                    break;
955
-
956
-                case 'border-right':
957
-                    $this->value['border']['r'] = $this->readBorder($val);
958
-                    break;
959
-
960
-                case 'border-bottom':
961
-                    $this->value['border']['b'] = $this->readBorder($val);
962
-                    break;
963
-
964
-                case 'border-left':
965
-                    $this->value['border']['l'] = $this->readBorder($val);
966
-                    break;
967
-
968
-                case 'background-color':
969
-                    $this->value['background']['color'] = $this->convertBackgroundColor($val);
970
-                    break;
971
-
972
-                case 'background-image':
973
-                    $this->value['background']['image'] = $this->convertBackgroundImage($val);
974
-                    break;
975
-
976
-                case 'background-position':
977
-                    $res = null;
978
-                    $this->value['background']['position'] = $this->convertBackgroundPosition($val, $res);
979
-                    break;
980
-
981
-                case 'background-repeat':
982
-                    $this->value['background']['repeat'] = $this->convertBackgroundRepeat($val);
983
-                    break;
984
-
985
-                case 'background':
986
-                    $this->convertBackground($val, $this->value['background']);
987
-                    break;
988
-
989
-                case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
992
-                    else                        $this->value['position'] = null;
993
-                    break;
994
-
995
-                case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
998
-                    else                        $this->value['float'] = null;
999
-                    break;
1000
-
1001
-                case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1005
-                    else                        $this->value['display'] = null;
1006
-                    break;
1007
-
1008
-                case 'top':
1009
-                case 'bottom':
1010
-                case 'left':
1011
-                case 'right':
1012
-                    $this->value[$nom] = $val;
1013
-                    break;
1014
-
1015
-                case 'list-style':
1016
-                case 'list-style-type':
1017
-                case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1019
-                    $this->value[$nom] = $val;
1020
-                    break;
1021
-
1022
-                default:
1023
-                    break;
1024
-            }
1025
-        }
1026
-
1027
-        $return = true;
1028
-
1029
-        // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1032
-
1033
-        // force the text align to left, if asked by html2pdf
1034
-        if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035
-
1036
-        // correction on the width (quick box)
1037
-        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1038
-            $this->value['width'] = $this->getLastWidth();
1039
-            $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1040
-        } else {
1041
-            if ($correctWidth) {
1042
-                if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
-                    $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
-                    $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045
-                }
1046
-                if (in_array($tagName, array('th', 'td'))) {
1047
-                    $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048
-                    $return = false;
1049
-                }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1051
-            } else {
1052
-                if ($this->value['width']) {
1053
-                    if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
-                    if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
-                    if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
-                    if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1057
-                }
1058
-            }
1059
-        }
1060
-        if ($this->value['height']) {
1061
-            if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
-            if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
-            if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
-            if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065
-        }
1066
-
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071
-
1072
-        if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
-        if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1074
-
1075
-        return $return;
1076
-    }
1077
-
1078
-     /**
1079
-     * get the height of the current line
1080
-     *
1081
-     * @access public
1082
-     * @return float $height in mm
1083
-     */
1084
-    public function getLineHeight()
1085
-    {
1086
-        $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1088
-        return $this->convertToMM($val, $this->value['font-size']);
1089
-    }
1090
-
1091
-     /**
1092
-     * get the width of the parent
1093
-     *
1094
-     * @access public
1095
-     * @param  boolean $mode true => adding padding and border
1096
-     * @return float $width in mm
1097
-     */
1098
-    public function getLastWidth($mode = false)
1099
-    {
1100
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1101
-            if ($this->table[$k]['width']) {
1102
-                $w = $this->table[$k]['width'];
1103
-                if ($mode) {
1104
-                    $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
-                    $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106
-                }
1107
-                return $w;
1108
-            }
1109
-        }
1110
-        return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin();
1111
-    }
1112
-
1113
-     /**
1114
-     * get the height of the parent
1115
-     *
1116
-     * @access public
1117
-     * @param  boolean $mode true => adding padding and border
1118
-     * @return float $height in mm
1119
-     */
1120
-    public function getLastHeight($mode = false)
1121
-    {
1122
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1123
-            if ($this->table[$k]['height']) {
1124
-                $h = $this->table[$k]['height'];
1125
-                if ($mode) {
1126
-                    $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
-                    $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128
-                }
1129
-                return $h;
1130
-            }
1131
-        }
1132
-        return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin();
1133
-    }
1134
-
1135
-    /**
1136
-     * get the value of the float property
1137
-     *
1138
-     * @access public
1139
-     * @return $float left/right
1140
-     */
1141
-    public function getFloat()
1142
-    {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1145
-        return null;
1146
-    }
1147
-
1148
-    /**
1149
-     * get the last value for a specific key
1150
-     *
1151
-     * @access public
1152
-     * @param  string $key
1153
-     * @return mixed
1154
-     */
1155
-    public function getLastValue($key)
1156
-    {
1157
-        $nb = count($this->table);
1158
-        if ($nb>0) {
1159
-            return $this->table[$nb-1][$key];
1160
-        } else {
1161
-            return null;
1162
-        }
1163
-    }
1164
-
1165
-    /**
1166
-     * get the last absolute X
1167
-     *
1168
-     * @access protected
1169
-     * @return float $x
1170
-     */
1171
-    protected function _getLastAbsoluteX()
1172
-    {
1173
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1174
-            if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175
-        }
1176
-        return $this->_pdf->getlMargin();
1177
-    }
1178
-
1179
-    /**
1180
-     * get the last absolute Y
1181
-     *
1182
-     * @access protected
1183
-     * @return float $y
1184
-     */
1185
-    protected function _getLastAbsoluteY()
1186
-    {
1187
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1188
-            if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189
-        }
1190
-        return $this->_pdf->gettMargin();
1191
-    }
1192
-
1193
-    /**
1194
-     * get the CSS properties of the current tag
1195
-     *
1196
-     * @access protected
1197
-     * @return array $styles
1198
-     */
1199
-    protected function _getFromCSS()
1200
-    {
1201
-        // styles to apply
1202
-        $styles = array();
1203
-
1204
-        // list of the selectors to get in the CSS files
1205
-        $getit  = array();
1206
-
1207
-        // get the list of the selectors of each tags
1208
-        $lst = array();
1209
-        $lst[] = $this->value['id_lst'];
1210
-        for ($i=count($this->table)-1; $i>=0; $i--) {
1211
-            $lst[] = $this->table[$i]['id_lst'];
1212
-        }
1213
-
1214
-        // foreach selectors in the CSS files, verify if it match with the list of selectors
1215
-        foreach ($this->cssKeys as $key => $num) {
1216
-            if ($this->_getReccursiveStyle($key, $lst)) {
1217
-                $getit[$key] = $num;
1218
-            }
1219
-        }
1220
-
1221
-        // if we have selectors
1222
-        if (count($getit)) {
1223
-            // get them, but in the definition order, because of priority
1224
-            asort($getit);
1225
-            foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1226
-        }
1227
-
1228
-        return $styles;
1229
-    }
1230
-
1231
-    /**
1232
-     * identify if the selector $key match with the list of tag selectors
1233
-     *
1234
-     * @access protected
1235
-     * @param  string   $key CSS selector to analyse
1236
-     * @param  array    $lst list of the selectors of each tags
1237
-     * @param  string   $next next step of parsing the selector
1238
-     * @return boolean
1239
-     */
1240
-    protected function _getReccursiveStyle($key, $lst, $next = null)
1241
-    {
1242
-        // if next step
1243
-        if ($next!==null) {
1244
-            // we remove this step
1245
-            if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246
-            array_shift($lst);
1247
-
1248
-            // if no more step to identify => return false
1249
-            if (!count($lst)) {
1250
-                return false;
1251
-            }
1252
-        }
1253
-
1254
-        // for each selector of the current step
1255
-        foreach ($lst[0] as $name) {
1256
-            // if selector = key => ok
1257
-            if ($key==$name) {
1258
-                return true;
1259
-            }
1260
-
1261
-            // if the end of the key = the selector and the next step is ok => ok
1262
-            if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263
-                return true;
1264
-            }
1265
-        }
1266
-
1267
-        // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
-        if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1269
-            return true;
1270
-        }
1271
-
1272
-        // no corresponding found
1273
-        return false;
1274
-    }
1275
-
1276
-    /**
1277
-     * Analyse a border
1278
-     *
1279
-     * @access  public
1280
-     * @param   string $css css border properties
1281
-     * @return  array  border properties
1282
-     */
1283
-    public function readBorder($css)
1284
-    {
1285
-        // border none
1286
-        $none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
1287
-
1288
-        // default value
1289
-        $type  = 'solid';
1290
-        $width = $this->convertToMM('1pt');
1291
-        $color = array(0, 0, 0);
1292
-
1293
-        // clean up the values
1294
-        $css = explode(' ', $css);
1295
-        foreach ($css as $k => $v) {
1296
-            $v = trim($v);
1297
-            if ($v) $css[$k] = $v;
1298
-            else    unset($css[$k]);
1299
-        }
1300
-        $css = array_values($css);
1301
-
1302
-        // read the values
1303
-        $res = null;
1304
-        foreach ($css as $value) {
1305
-
1306
-            // if no border => return none
1307
-            if ($value=='none' || $value=='hidden') {
1308
-                return $none;
1309
-            }
1310
-
1311
-            // try to convert the value as a distance
1312
-            $tmp = $this->convertToMM($value);
1313
-
1314
-            // if the convert is ok => it is a width
1315
-            if ($tmp!==null) {
1316
-                $width = $tmp;
1317
-            // else, it could be the type
1318
-            } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
1319
-                $type = $value;
1320
-            // else, it could be the color
1321
-            } else {
1322
-                $tmp = $this->convertToColor($value, $res);
1323
-                if ($res) $color = $tmp;
1324
-            }
1325
-        }
1326
-
1327
-        // if no witdh => return none
1328
-        if (!$width) return $none;
1329
-
1330
-        // return the border properties
1331
-        return array('type' => $type, 'width' => $width, 'color' => $color);
1332
-    }
1333
-
1334
-    /**
1335
-     * duplicate the borders if needed
1336
-     *
1337
-     * @access protected
1338
-     * @param  &array $val
1339
-     */
1340
-    protected function _duplicateBorder(&$val)
1341
-    {
1342
-        // 1 value => L => RTB
1343
-        if (count($val)==1) {
1344
-            $val[1] = $val[0];
1345
-            $val[2] = $val[0];
1346
-            $val[3] = $val[0];
1347
-        // 2 values => L => R & T => B
1348
-        } else if (count($val)==2) {
1349
-            $val[2] = $val[0];
1350
-            $val[3] = $val[1];
1351
-        // 3 values => T => B
1352
-        } else if (count($val)==3) {
1353
-            $val[3] = $val[1];
1354
-        }
1355
-    }
1356
-
1357
-    /**
1358
-     * Analyse a background
1359
-     *
1360
-     * @access public
1361
-     * @param  string $css css background properties
1362
-     * @param  &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties)
1363
-     */
1364
-    public function convertBackground($css, &$value)
1365
-    {
1366
-        // is there a image ?
1367
-        $text = '/url\(([^)]*)\)/isU';
1368
-        if (preg_match($text, $css, $match)) {
1369
-            // get the image
1370
-            $value['image'] = $this->convertBackgroundImage($match[0]);
1371
-
1372
-            // remove if from the css properties
1373
-            $css = preg_replace($text, '', $css);
1374
-            $css = preg_replace('/[\s]+/', ' ', $css);
1375
-        }
1376
-
1377
-        // protect some spaces
1378
-        $css = preg_replace('/,[\s]+/', ',', $css);
1379
-
1380
-        // explode the values
1381
-        $css = explode(' ', $css);
1382
-
1383
-        // background position to parse
1384
-        $pos = '';
1385
-
1386
-        // foreach value
1387
-        foreach ($css as $val) {
1388
-            // try to parse the value as a color
1389
-            $ok = false;
1390
-            $color = $this->convertToColor($val, $ok);
1391
-
1392
-            // if ok => it is a color
1393
-            if ($ok) {
1394
-                $value['color'] = $color;
1395
-            // else if transparent => no coloàr
1396
-            } else if ($val=='transparent') {
1397
-                $value['color'] = null;
1398
-            // else
1399
-            } else {
1400
-                // try to parse the value as a repeat
1401
-                $repeat = $this->convertBackgroundRepeat($val);
1402
-
1403
-                // if ok => it is repeat
1404
-                if ($repeat) {
1405
-                    $value['repeat'] = $repeat;
1406
-                // else => it could only be a position
1407
-                } else {
1408
-                    $pos.= ($pos ? ' ' : '').$val;
1409
-                }
1410
-            }
1411
-        }
1412
-
1413
-        // if we have a position to parse
1414
-        if ($pos) {
1415
-            // try to read it
1416
-            $pos = $this->convertBackgroundPosition($pos, $ok);
1417
-            if ($ok) $value['position'] = $pos;
1418
-        }
1419
-    }
1420
-
1421
-    /**
1422
-     * parse a background color
1423
-     *
1424
-     * @access public
1425
-     * @param  string $css
1426
-     * @return string $value
1427
-     */
1428
-    public function convertBackgroundColor($css)
1429
-    {
1430
-        $res = null;
1431
-        if ($css=='transparent') return null;
1432
-        else                     return $this->convertToColor($css, $res);
1433
-    }
1434
-
1435
-    /**
1436
-     * parse a background image
1437
-     *
1438
-     * @access public
1439
-     * @param  string $css
1440
-     * @return string $value
1441
-     */
1442
-    public function convertBackgroundImage($css)
1443
-    {
1444
-        if ($css=='none')
1445
-            return null;
1446
-        else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
-            return $match[1];
1448
-        else
1449
-            return null;
1450
-    }
1451
-
1452
-    /**
1453
-     * parse a background position
1454
-     *
1455
-     * @access public
1456
-     * @param  string $css
1457
-     * @param  &boolean $res flag if conver is ok or not
1458
-     * @return array ($x, $y)
1459
-     */
1460
-    public function convertBackgroundPosition($css, &$res)
1461
-    {
1462
-        // init the res
1463
-        $res = false;
1464
-
1465
-        // explode the value
1466
-        $css = explode(' ', $css);
1467
-
1468
-        // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
-        if (count($css)<2) {
1470
-            if (!$css[0]) return null;
1471
-            $css[1] = 'center';
1472
-        }
1473
-        if (count($css)>2) return null;
1474
-
1475
-        // prepare the values
1476
-        $x = 0;
1477
-        $y = 0;
1478
-        $res = true;
1479
-
1480
-        // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1486
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
-        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
-        else $res = false;
1489
-
1490
-        // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1496
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
-        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
-        else $res = false;
1499
-
1500
-        // return the values
1501
-        return array($x, $y);
1502
-    }
1503
-
1504
-    /**
1505
-     * parse a background repeat
1506
-     *
1507
-     * @access public
1508
-     * @param  string $css
1509
-     * @return string $value
1510
-     */
1511
-    public function convertBackgroundRepeat($css)
1512
-    {
1513
-        switch($css)
1514
-        {
1515
-            case 'repeat':
1516
-                return array(true, true);
1517
-            case 'repeat-x':
1518
-                return array(true, false);
1519
-            case 'repeat-y':
1520
-                return array(false, true);
1521
-            case 'no-repeat':
1522
-                return array(false, false);
1523
-        }
1524
-        return null;
1525
-    }
1526
-
1527
-     /**
1528
-     * convert a distance to mm
1529
-     *
1530
-     * @access public
1531
-     * @param  string $css distance to convert
1532
-     * @param  float  $old parent distance
1533
-     * @return float  $value
1534
-     */
1535
-    public function convertToMM($css, $old=0.)
1536
-    {
1537
-        $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
-        else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
-        else                                              $css = null;
1545
-
1546
-        return $css;
1547
-    }
1548
-
1549
-    /**
1550
-     * convert a css radius
1551
-     *
1552
-     * @access public
1553
-     * @param  string $css
1554
-     * @return float  $value
1555
-     */
1556
-    public function convertToRadius($css)
1557
-    {
1558
-        // explode the value
1559
-        $css = explode(' ', $css);
1560
-
1561
-        foreach ($css as $k => $v) {
1562
-            $v = trim($v);
1563
-            if ($v) {
1564
-                $v = $this->convertToMM($v, 0);
1565
-                if ($v!==null) {
1566
-                    $css[$k] = $v;
1567
-                } else {
1568
-                    unset($css[$k]);
1569
-                }
1570
-            } else {
1571
-                unset($css[$k]);
1572
-            }
1573
-        }
1574
-
1575
-        return array_values($css);
1576
-    }
1577
-
1578
-    /**
1579
-     * convert a css color
1580
-     *
1581
-     * @access public
1582
-     * @param  string $css
1583
-     * @param  &boolean $res
1584
-     * @return array (r,g, b)
1585
-     */
1586
-    public function convertToColor($css, &$res)
1587
-    {
1588
-        // prepare the value
1589
-        $css = trim($css);
1590
-        $res = true;
1591
-
1592
-        // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1594
-
1595
-        // HTML color
1596
-        if (isset($this->_htmlColor[strtolower($css)])) {
1597
-            $css = $this->_htmlColor[strtolower($css)];
1598
-            $r = floatVal(hexdec(substr($css, 0, 2)));
1599
-            $v = floatVal(hexdec(substr($css, 2, 2)));
1600
-            $b = floatVal(hexdec(substr($css, 4, 2)));
1601
-            return array($r, $v, $b);
1602
-        }
1603
-
1604
-        // like #FFFFFF
1605
-        if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) {
1606
-            $r = floatVal(hexdec(substr($css, 1, 2)));
1607
-            $v = floatVal(hexdec(substr($css, 3, 2)));
1608
-            $b = floatVal(hexdec(substr($css, 5, 2)));
1609
-            return array($r, $v, $b);
1610
-        }
1611
-
1612
-        // like #FFF
1613
-        if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
-            $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
-            $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
-            $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1617
-            return array($r, $v, $b);
1618
-        }
1619
-
1620
-        // like rgb(100, 100, 100)
1621
-        if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1622
-            $r = $this->_convertSubColor($match[1]);
1623
-            $v = $this->_convertSubColor($match[2]);
1624
-            $b = $this->_convertSubColor($match[3]);
1625
-            return array($r*255., $v*255., $b*255.);
1626
-        }
1627
-
1628
-        // like cmyk(100, 100, 100, 100)
1629
-        if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1630
-            $c = $this->_convertSubColor($match[1]);
1631
-            $m = $this->_convertSubColor($match[2]);
1632
-            $y = $this->_convertSubColor($match[3]);
1633
-            $k = $this->_convertSubColor($match[4]);
1634
-            return array($c*100., $m*100., $y*100., $k*100.);
1635
-        }
1636
-
1637
-        $res = false;
1638
-        return array(0., 0., 0.);
1639
-    }
1640
-
1641
-    /**
1642
-     * color value to convert
1643
-     *
1644
-     * @access protected
1645
-     * @param  string $c
1646
-     * @return float $c 0.->1.
1647
-     */
1648
-    protected function _convertSubColor($c)
1649
-    {
1650
-        if (substr($c, -1)=='%') {
1651
-            $c = floatVal(substr($c, 0, -1))/100.;
1652
-        } else {
1653
-            $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1655
-        }
1656
-
1657
-        return $c;
1658
-    }
1659
-
1660
-    /**
1661
-     * read a css content
1662
-     *
1663
-     * @access protected
1664
-     * @param  &string $code
1665
-     */
1666
-    protected function _analyseStyle(&$code)
1667
-    {
1668
-        // clean the spaces
1669
-        $code = preg_replace('/[\s]+/', ' ', $code);
1670
-
1671
-        // remove the comments
1672
-        $code = preg_replace('/\/\*.*?\*\//s', '', $code);
1673
-
1674
-        // split each CSS code "selector { value }"
1675
-        preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676
-
1677
-        // for each CSS code
1678
-        for ($k=0; $k<count($match[0]); $k++) {
1679
-
1680
-            // selectors
1681
-            $names = strtolower(trim($match[1][$k]));
1682
-
1683
-            // css style
1684
-            $styles = trim($match[2][$k]);
1685
-
1686
-            // explode each value
1687
-            $styles = explode(';', $styles);
1688
-
1689
-            // parse each value
1690
-            $css = array();
1691
-            foreach ($styles as $style) {
1692
-                $tmp = explode(':', $style);
1693
-                if (count($tmp)>1) {
1694
-                    $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695
-                    $css[trim(strtolower($cod))] = trim($tmp);
1696
-                }
1697
-            }
1698
-
1699
-            // explode the names
1700
-            $names = explode(',', $names);
1701
-
1702
-            // save the values for each names
1703
-            foreach ($names as $name) {
1704
-                // clean the name
1705
-                $name = trim($name);
1706
-
1707
-                // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1709
-
1710
-                // save the value
1711
-                if (!isset($this->css[$name]))
1712
-                    $this->css[$name] = $css;
1713
-                else
1714
-                    $this->css[$name] = array_merge($this->css[$name], $css);
1715
-
1716
-            }
1717
-        }
1718
-
1719
-        // get he list of the keys
1720
-        $this->cssKeys = array_flip(array_keys($this->css));
1721
-    }
1722
-
1723
-    /**
1724
-     * Extract the css files from a html code
1725
-     *
1726
-     * @access public
1727
-     * @param  string   &$html
1728
-     */
1729
-    public function readStyle(&$html)
1730
-    {
1731
-        // the CSS content
1732
-        $style = ' ';
1733
-
1734
-        // extract the link tags, and remove them in the html code
1735
-        preg_match_all('/<link([^>]*)>/isU', $html, $match);
1736
-        $html = preg_replace('/<link[^>]*>/isU', '', $html);
1737
-        $html = preg_replace('/<\/link[^>]*>/isU', '', $html);
1738
-
1739
-        // analyse each link tag
1740
-        foreach ($match[1] as $code) {
1741
-            $tmp = array();
1742
-
1743
-            // read the attributes name=value
1744
-            $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
-            preg_match_all('/'.$prop.'/is', $code, $match);
1746
-            for ($k=0; $k<count($match[0]); $k++) {
1747
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748
-            }
1749
-
1750
-            // read the attributes name="value"
1751
-            $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
-            preg_match_all('/'.$prop.'/is', $code, $match);
1753
-            for ($k=0; $k<count($match[0]); $k++) {
1754
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755
-            }
1756
-
1757
-            // read the attributes name='value'
1758
-            $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
-            preg_match_all('/'.$prop.'/is', $code, $match);
1760
-            for ($k=0; $k<count($match[0]); $k++) {
1761
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762
-            }
1763
-
1764
-            // if type text/css => we keep it
1765
-            if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1766
-
1767
-                // get the href
1768
-                $url = $tmp['href'];
1769
-
1770
-                // get the content of the css file
1771
-                $content = @file_get_contents($url);
1772
-
1773
-                // if "http://" in the url
1774
-                if (strpos($url, 'http://')!==false) {
1775
-
1776
-                    // get the domain "http://xxx/"
1777
-                    $url = str_replace('http://', '', $url);
1778
-                    $url = explode('/', $url);
1779
-                    $urlMain = 'http://'.$url[0].'/';
1780
-
1781
-                    // get the absolute url of the path
1782
-                    $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1783
-
1784
-                    // adapt the url in the css content
1785
-                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
-                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1787
-                } else {
14
+	/**
15
+	 * reference to the pdf object
16
+	 * @var TCPDF
17
+	 */
18
+	protected $_pdf         = null;
19
+
20
+	protected $_htmlColor   = array(); // list of the HTML colors
21
+	protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
+	protected $_defaultFont = null;    // default font to use if the asked font does not exist
23
+
24
+	public    $value        = array(); // current values
25
+	public    $css          = array(); // css values
26
+	public    $cssKeys      = array(); // css key, for the execution order
27
+	public    $table        = array(); // level history
28
+
29
+	/**
30
+	 * Constructor
31
+	 *
32
+	 * @param  &HTML2PDF_myPdf reference to the PDF $object
33
+	 * @access public
34
+	 */
35
+	public function __construct(&$pdf)
36
+	{
37
+		$this->_init();
38
+		$this->setPdfParent($pdf);
39
+	}
40
+
41
+	/**
42
+	 * Set the HTML2PDF parent object
43
+	 *
44
+	 * @param  &HTML2PDF reference to the HTML2PDF parent $object
45
+	 * @access public
46
+	 */
47
+	public function setPdfParent(&$pdf)
48
+	{
49
+		$this->_pdf = &$pdf;
50
+	}
51
+
52
+	/**
53
+	 * Inform that we want only "test-align:left" because we are in a sub HTML
54
+	 *
55
+	 * @access public
56
+	 */
57
+	public function setOnlyLeft()
58
+	{
59
+		$this->value['text-align'] = 'left';
60
+		$this->_onlyLeft = true;
61
+	}
62
+
63
+	/**
64
+	 * Get the vales of the parent, if exist
65
+	 *
66
+	 * @return array CSS values
67
+	 * @access public
68
+	 */
69
+	public function getOldValues()
70
+	{
71
+		return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
72
+	}
73
+
74
+	/**
75
+	 * define the Default Font to use, if the font does not exist, or if no font asked
76
+	 *
77
+	 * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
78
+	 * @return string  old default font-family
79
+	 * @access public
80
+	 */
81
+	public function setDefaultFont($default = null)
82
+	{
83
+		$old = $this->_defaultFont;
84
+		$this->_defaultFont = $default;
85
+		if ($default) $this->value['font-family'] = $default;
86
+		return $old;
87
+	}
88
+
89
+	 /**
90
+	  * Init the object
91
+	  *
92
+	  * @access protected
93
+	  */
94
+	protected function _init()
95
+	{
96
+		// get the Web Colors from TCPDF
97
+		require(K_PATH_MAIN.'htmlcolors.php');
98
+		$this->_htmlColor = $webcolor;
99
+
100
+		// init the Style
101
+		$this->table = array();
102
+		$this->value = array();
103
+		$this->initStyle();
104
+
105
+		// Init the styles without legacy
106
+		$this->resetStyle();
107
+	}
108
+
109
+	/**
110
+	 * Init the CSS Style
111
+	 *
112
+	 * @access public
113
+	 */
114
+	public function initStyle()
115
+	{
116
+		$this->value['id_tag']       = 'body';        // tag name
117
+		$this->value['id_name']          = null;         // tag - attribute name
118
+		$this->value['id_id']            = null;         // tag - attribute id
119
+		$this->value['id_class']         = null;         // tag - attribute class
120
+		$this->value['id_lst']           = array('*');   // tag - list of legacy
121
+		$this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
+		$this->value['mini-decal']       = 0;            // specific position report for sup, sub
123
+		$this->value['font-family']      = 'Arial';
124
+		$this->value['font-bold']        = false;
125
+		$this->value['font-italic']      = false;
126
+		$this->value['font-underline']   = false;
127
+		$this->value['font-overline']    = false;
128
+		$this->value['font-linethrough'] = false;
129
+		$this->value['text-transform']   = 'none';
130
+		$this->value['font-size']        = $this->convertToMM('10pt');
131
+		$this->value['text-indent']      = 0;
132
+		$this->value['text-align']       = 'left';
133
+		$this->value['vertical-align']   = 'middle';
134
+		$this->value['line-height']      = 'normal';
135
+
136
+		$this->value['position']         = null;
137
+		$this->value['x']                = null;
138
+		$this->value['y']                = null;
139
+		$this->value['width']            = 0;
140
+		$this->value['height']           = 0;
141
+		$this->value['top']              = null;
142
+		$this->value['right']            = null;
143
+		$this->value['bottom']           = null;
144
+		$this->value['left']             = null;
145
+		$this->value['float']            = null;
146
+		$this->value['display']          = null;
147
+		$this->value['rotate']           = null;
148
+		$this->value['overflow']         = 'visible';
149
+
150
+		$this->value['color']            = array(0, 0, 0);
151
+		$this->value['background']       = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
152
+		$this->value['border']           = array();
153
+		$this->value['padding']          = array();
154
+		$this->value['margin']           = array();
155
+		$this->value['margin-auto']      = false;
156
+
157
+		$this->value['list-style-type']  = '';
158
+		$this->value['list-style-image'] = '';
159
+
160
+		$this->value['xc'] = null;
161
+		$this->value['yc'] = null;
162
+	}
163
+
164
+	/**
165
+	 * Init the CSS Style without legacy
166
+	 *
167
+	 * @param  string  tag name
168
+	 * @access public
169
+	 */
170
+	public function resetStyle($tagName = '')
171
+	{
172
+		// prepare somme values
173
+		$border = $this->readBorder('solid 1px #000000');
174
+		$units = array(
175
+			'1px' => $this->convertToMM('1px'),
176
+			'5px' => $this->convertToMM('5px'),
177
+		);
178
+
179
+
180
+		// prepare the Collapse attribute
181
+		$collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
+		if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
183
+
184
+		// set the global css values
185
+		$this->value['position']   = null;
186
+		$this->value['x']          = null;
187
+		$this->value['y']          = null;
188
+		$this->value['width']      = 0;
189
+		$this->value['height']     = 0;
190
+		$this->value['top']        = null;
191
+		$this->value['right']      = null;
192
+		$this->value['bottom']     = null;
193
+		$this->value['left']       = null;
194
+		$this->value['float']      = null;
195
+		$this->value['display']    = null;
196
+		$this->value['rotate']     = null;
197
+		$this->value['overflow']   = 'visible';
198
+		$this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
199
+		$this->value['border']     = array(
200
+			't' => $this->readBorder('none'),
201
+			'r' => $this->readBorder('none'),
202
+			'b' => $this->readBorder('none'),
203
+			'l' => $this->readBorder('none'),
204
+			'radius' => array(
205
+				'tl' => array(0, 0),
206
+				'tr' => array(0, 0),
207
+				'br' => array(0, 0),
208
+				'bl' => array(0, 0)
209
+			),
210
+			'collapse' => $collapse,
211
+		);
212
+
213
+		// specific values for some tags
214
+		if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
+			$this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
216
+		}
217
+
218
+		if (in_array($tagName, array('input', 'select', 'textarea'))) {
219
+			$this->value['border']['t'] = null;
220
+			$this->value['border']['r'] = null;
221
+			$this->value['border']['b'] = null;
222
+			$this->value['border']['l'] = null;
223
+		}
224
+
225
+		if ($tagName=='p') {
226
+			$this->value['margin']['t'] = null;
227
+			$this->value['margin']['b'] = null;
228
+		}
229
+		if ($tagName=='blockquote') {
230
+			$this->value['margin']['t'] = 3;
231
+			$this->value['margin']['r'] = 3;
232
+			$this->value['margin']['b'] = 3;
233
+			$this->value['margin']['l'] = 6;
234
+		}
235
+		$this->value['margin-auto'] = false;
236
+
237
+		if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) {
238
+			$this->value['vertical-align'] = 'top';
239
+		}
240
+
241
+		if (in_array($tagName, array('fieldset', 'legend'))) {
242
+			$this->value['border'] = array(
243
+				't' => $border,
244
+				'r' => $border,
245
+				'b' => $border,
246
+				'l' => $border,
247
+				'radius' => array(
248
+					'tl' => array($units['5px'], $units['5px']),
249
+					'tr' => array($units['5px'], $units['5px']),
250
+					'br' => array($units['5px'], $units['5px']),
251
+					'bl' => array($units['5px'], $units['5px'])
252
+				),
253
+				'collapse' => false,
254
+			);
255
+		}
256
+
257
+		if (in_array($tagName, array('ul', 'li'))) {
258
+			$this->value['list-style-type']  = '';
259
+			$this->value['list-style-image'] = '';
260
+		}
261
+
262
+		if (!in_array($tagName, array('tr', 'td'))) {
263
+			$this->value['padding'] = array(
264
+				't' => 0,
265
+				'r' => 0,
266
+				'b' => 0,
267
+				'l' => 0
268
+			);
269
+		} else {
270
+			$this->value['padding'] = array(
271
+				't' => $units['1px'],
272
+				'r' => $units['1px'],
273
+				'b' => $units['1px'],
274
+				'l' => $units['1px']
275
+			);
276
+		}
277
+
278
+		if ($tagName=='hr') {
279
+			$this->value['border'] = array(
280
+				't' => $border,
281
+				'r' => $border,
282
+				'b' => $border,
283
+				'l' => $border,
284
+				'radius' => array(
285
+					'tl' => array(0, 0),
286
+					'tr' => array(0, 0),
287
+					'br' => array(0, 0),
288
+					'bl' => array(0, 0)
289
+				),
290
+				'collapse' => false,
291
+			);
292
+			$this->convertBackground('#FFFFFF', $this->value['background']);
293
+		}
294
+
295
+		$this->value['xc'] = null;
296
+		$this->value['yc'] = null;
297
+	}
298
+
299
+	/**
300
+	 * Init the PDF Font
301
+	 *
302
+	 * @access public
303
+	 */
304
+	public function fontSet()
305
+	{
306
+		$family = strtolower($this->value['font-family']);
307
+
308
+		$b = ($this->value['font-bold']        ? 'B' : '');
309
+		$i = ($this->value['font-italic']      ? 'I' : '');
310
+		$u = ($this->value['font-underline']   ? 'U' : '');
311
+		$d = ($this->value['font-linethrough'] ? 'D' : '');
312
+		$o = ($this->value['font-overline']    ? 'O' : '');
313
+
314
+		// font style
315
+		$style = $b.$i;
316
+
317
+		if ($this->_defaultFont) {
318
+			if($family=='arial')
319
+				$family='helvetica';
320
+			elseif($family=='symbol' || $family=='zapfdingbats')
321
+				$style='';
322
+
323
+			$fontkey = $family.$style;
324
+			if (!$this->_pdf->isLoadedFont($fontkey))
325
+				$family = $this->_defaultFont;
326
+		}
327
+
328
+		if($family=='arial')
329
+			$family='helvetica';
330
+		elseif($family=='symbol' || $family=='zapfdingbats')
331
+			$style='';
332
+
333
+		// complete style
334
+		$style.= $u.$d.$o;
335
+
336
+		// size : mm => pt
337
+		$size = $this->value['font-size'];
338
+		$size = 72 * $size / 25.4;
339
+
340
+		// apply the font
341
+		$this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342
+		$this->_pdf->setTextColorArray($this->value['color']);
343
+		if ($this->value['background']['color'])
344
+			$this->_pdf->setFillColorArray($this->value['background']['color']);
345
+		else
346
+			$this->_pdf->setFillColor(255);
347
+	}
348
+
349
+	 /**
350
+	  * add a level in the CSS history
351
+	  *
352
+	  * @access public
353
+	  */
354
+	public function save()
355
+	{
356
+		array_push($this->table, $this->value);
357
+	}
358
+
359
+	 /**
360
+	  * remove a level in the CSS history
361
+	  *
362
+	  * @access public
363
+	  */
364
+	public function load()
365
+	{
366
+		if (count($this->table)) {
367
+			$this->value = array_pop($this->table);
368
+		}
369
+	}
370
+
371
+	 /**
372
+	  * restore the Y positiony (used after a span)
373
+	  *
374
+	  * @access public
375
+	  */
376
+	public function restorePosition()
377
+	{
378
+		if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379
+	}
380
+
381
+	 /**
382
+	  * set the New position for the current Tag
383
+	  *
384
+	  * @access public
385
+	  */
386
+	public function setPosition()
387
+	{
388
+		// get the current position
389
+		$currentX = $this->_pdf->getX();
390
+		$currentY = $this->_pdf->getY();
391
+
392
+		// save it
393
+		$this->value['xc'] = $currentX;
394
+		$this->value['yc'] = $currentY;
395
+
396
+		if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
+			if ($this->value['right']!==null) {
398
+				$x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
+				if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
400
+			} else {
401
+				$x = $this->value['left'];
402
+				if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
403
+			}
404
+
405
+			if ($this->value['bottom']!==null) {
406
+				$y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
+				if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
408
+			} else {
409
+				$y = $this->value['top'];
410
+				if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
411
+			}
412
+
413
+			if ($this->value['position']=='relative') {
414
+				$this->value['x'] = $currentX + $x;
415
+				$this->value['y'] = $currentY + $y;
416
+			} else {
417
+				$this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
+				$this->value['y'] = $this->_getLastAbsoluteY()+$y;
419
+			}
420
+		} else {
421
+			$this->value['x'] = $currentX;
422
+			$this->value['y'] = $currentY;
423
+			if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
+			if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
425
+		}
426
+
427
+		// save the new position
428
+		$this->_pdf->setXY($this->value['x'], $this->value['y']);
429
+	}
430
+
431
+	 /**
432
+	  * Analise the CSS style to convert it into Form style
433
+	  *
434
+	  * @access public
435
+	  * @param  array    styles
436
+	  */
437
+	public function getFormStyle()
438
+	{
439
+		$prop = array();
440
+
441
+		$prop['alignment'] = $this->value['text-align'];
442
+
443
+		if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) {
444
+			$prop['fillColor'] = $this->value['background']['color'];
445
+		}
446
+
447
+		if (isset($this->value['border']['t']['color'])) {
448
+			$prop['strokeColor'] = $this->value['border']['t']['color'];
449
+		}
450
+
451
+		if (isset($this->value['border']['t']['width'])) {
452
+			$prop['lineWidth'] = $this->value['border']['t']['width'];
453
+		}
454
+
455
+		if (isset($this->value['border']['t']['type'])) {
456
+			$prop['borderStyle'] = $this->value['border']['t']['type'];
457
+		}
458
+
459
+		if (!empty($this->value['color'])) {
460
+			$prop['textColor'] = $this->value['color'];
461
+		}
462
+
463
+		if (!empty($this->value['font-size'])) {
464
+			$prop['textSize'] = $this->value['font-size'];
465
+		}
466
+
467
+		return $prop;
468
+	}
469
+
470
+	 /**
471
+	  * Analise the CSS style to convert it into SVG style
472
+	  *
473
+	  * @access public
474
+	  * @param  string   tag name
475
+	  * @param  array    styles
476
+	  */
477
+	public function getSvgStyle($tagName, &$param)
478
+	{
479
+		// prepare
480
+		$tagName = strtolower($tagName);
481
+		$id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
+		$name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483
+
484
+		// read the class attribute
485
+		$class = array();
486
+		$tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
487
+		$tmp = explode(' ', $tmp);
488
+		foreach ($tmp as $k => $v) {
489
+			$v = trim($v);
490
+			if ($v) $class[] = $v;
491
+		}
492
+
493
+		// identify the tag, and the direct styles
494
+		$this->value['id_tag'] = $tagName;
495
+		$this->value['id_name']   = $name;
496
+		$this->value['id_id']     = $id;
497
+		$this->value['id_class']  = $class;
498
+		$this->value['id_lst']    = array();
499
+		$this->value['id_lst'][] = '*';
500
+		$this->value['id_lst'][] = $tagName;
501
+		if (!isset($this->value['svg'])) {
502
+			$this->value['svg'] = array(
503
+				'stroke'         => null,
504
+				'stroke-width'   => $this->convertToMM('1pt'),
505
+				'fill'           => null,
506
+				'fill-opacity'   => null,
507
+			);
508
+		}
509
+
510
+		if (count($class)) {
511
+			foreach ($class as $v) {
512
+				$this->value['id_lst'][] = '*.'.$v;
513
+				$this->value['id_lst'][] = '.'.$v;
514
+				$this->value['id_lst'][] = $tagName.'.'.$v;
515
+			}
516
+		}
517
+		if ($id) {
518
+			$this->value['id_lst'][] = '*#'.$id;
519
+			$this->value['id_lst'][] = '#'.$id;
520
+			$this->value['id_lst'][] = $tagName.'#'.$id;
521
+		}
522
+
523
+		// CSS style
524
+		$styles = $this->_getFromCSS();
525
+
526
+		// adding the style from the tag
527
+		$styles = array_merge($styles, $param['style']);
528
+
529
+		if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
+		if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
+		if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
+		if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
533
+
534
+		return $this->value['svg'];
535
+	}
536
+
537
+	/**
538
+	 * analyse the css properties from the HTML parsing
539
+	 *
540
+	 * @access public
541
+	 * @param  string  $tagName
542
+	 * @param  array   $param
543
+	 * @param  array   $legacy
544
+	 */
545
+	public function analyse($tagName, &$param, $legacy = null)
546
+	{
547
+		// prepare the informations
548
+		$tagName = strtolower($tagName);
549
+		$id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
+		$name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
551
+
552
+		// get the class names to use
553
+		$class = array();
554
+		$tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
555
+		$tmp = explode(' ', $tmp);
556
+		foreach ($tmp as $k => $v) {
557
+			$v = trim($v);
558
+			if ($v) $class[] = $v;
559
+		}
560
+
561
+		// prepare the values, and the list of css tags to identify
562
+		$this->value['id_tag']   = $tagName;
563
+		$this->value['id_name']  = $name;
564
+		$this->value['id_id']    = $id;
565
+		$this->value['id_class'] = $class;
566
+		$this->value['id_lst']   = array();
567
+		$this->value['id_lst'][] = '*';
568
+		$this->value['id_lst'][] = $tagName;
569
+		if (count($class)) {
570
+			foreach ($class as $v) {
571
+				$this->value['id_lst'][] = '*.'.$v;
572
+				$this->value['id_lst'][] = '.'.$v;
573
+				$this->value['id_lst'][] = $tagName.'.'.$v;
574
+			}
575
+		}
576
+		if ($id) {
577
+			$this->value['id_lst'][] = '*#'.$id;
578
+			$this->value['id_lst'][] = '#'.$id;
579
+			$this->value['id_lst'][] = $tagName.'#'.$id;
580
+		}
581
+
582
+		// get the css styles from class
583
+		$styles = $this->_getFromCSS();
584
+
585
+		// merge with the css styles from tag
586
+		$styles = array_merge($styles, $param['style']);
587
+		if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
588
+
589
+		// reset some styles, depending on the tag name
590
+		$this->resetStyle($tagName);
591
+
592
+		// add the legacy values
593
+		if ($legacy) {
594
+			foreach ($legacy as $legacyName => $legacyValue) {
595
+				if (is_array($legacyValue)) {
596
+					foreach($legacyValue as $legacy2Name => $legacy2Value)
597
+						$this->value[$legacyName][$legacy2Name] = $legacy2Value;
598
+				} else {
599
+					$this->value[$legacyName] = $legacyValue;
600
+				}
601
+			}
602
+		}
603
+
604
+		// some flags
605
+		$correctWidth = false;
606
+		$noWidth = true;
607
+
608
+		// read all the css styles
609
+		foreach ($styles as $nom => $val) {
610
+			switch($nom)
611
+			{
612
+				case 'font-family':
613
+					$val = explode(',', $val);
614
+					$val = trim($val[0]);
615
+					if ($val) $this->value['font-family'] = $val;
616
+					break;
617
+
618
+				case 'font-weight':
619
+					$this->value['font-bold'] = ($val=='bold');
620
+					break;
621
+
622
+				case 'font-style':
623
+					$this->value['font-italic'] = ($val=='italic');
624
+					break;
625
+
626
+				case 'text-decoration':
627
+					$val = explode(' ', $val);
628
+					$this->value['font-underline']   = (in_array('underline', $val));
629
+					$this->value['font-overline']    = (in_array('overline', $val));
630
+					$this->value['font-linethrough'] = (in_array('line-through', $val));
631
+					break;
632
+
633
+				case 'text-indent':
634
+					$this->value['text-indent'] = $this->convertToMM($val);
635
+					break;
636
+
637
+				case 'text-transform':
638
+					if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
+					$this->value['text-transform']  = $val;
640
+					break;
641
+
642
+				case 'font-size':
643
+					$val = $this->convertToMM($val, $this->value['font-size']);
644
+					if ($val) $this->value['font-size'] = $val;
645
+					break;
646
+
647
+				case 'color':
648
+					$res = null;
649
+					$this->value['color'] = $this->convertToColor($val, $res);
650
+					if ($tagName=='hr') {
651
+						$this->value['border']['l']['color'] = $this->value['color'];
652
+						$this->value['border']['t']['color'] = $this->value['color'];
653
+						$this->value['border']['r']['color'] = $this->value['color'];
654
+						$this->value['border']['b']['color'] = $this->value['color'];
655
+					}
656
+					break;
657
+
658
+				case 'text-align':
659
+					$val = strtolower($val);
660
+					if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
661
+					$this->value['text-align'] = $val;
662
+					break;
663
+
664
+				case 'vertical-align':
665
+					$this->value['vertical-align'] = $val;
666
+					break;
667
+
668
+				case 'width':
669
+					$this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
+					if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
671
+					$noWidth = false;
672
+					break;
673
+
674
+				case 'height':
675
+					$this->value['height'] = $this->convertToMM($val, $this->getLastHeight());
676
+					break;
677
+
678
+				case 'line-height':
679
+					if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
680
+					$this->value['line-height'] = $val;
681
+					break;
682
+
683
+				case 'rotate':
684
+					if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
+					if ($val<0) $val+= 360;
686
+					$this->value['rotate'] = $val;
687
+					break;
688
+
689
+				case 'overflow':
690
+					if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
691
+					$this->value['overflow'] = $val;
692
+					break;
693
+
694
+				case 'padding':
695
+					$val = explode(' ', $val);
696
+					foreach ($val as $k => $v) {
697
+						$v = trim($v);
698
+						if ($v!='') {
699
+							$val[$k] = $v;
700
+						} else {
701
+							unset($val[$k]);
702
+						}
703
+					}
704
+					$val = array_values($val);
705
+					$this->_duplicateBorder($val);
706
+					$this->value['padding']['t'] = $this->convertToMM($val[0], 0);
707
+					$this->value['padding']['r'] = $this->convertToMM($val[1], 0);
708
+					$this->value['padding']['b'] = $this->convertToMM($val[2], 0);
709
+					$this->value['padding']['l'] = $this->convertToMM($val[3], 0);
710
+					break;
711
+
712
+				case 'padding-top':
713
+					$this->value['padding']['t'] = $this->convertToMM($val, 0);
714
+					break;
715
+
716
+				case 'padding-right':
717
+					$this->value['padding']['r'] = $this->convertToMM($val, 0);
718
+					break;
719
+
720
+				case 'padding-bottom':
721
+					$this->value['padding']['b'] = $this->convertToMM($val, 0);
722
+					break;
723
+
724
+				case 'padding-left':
725
+					$this->value['padding']['l'] = $this->convertToMM($val, 0);
726
+					break;
727
+
728
+				case 'margin':
729
+					if ($val=='auto') {
730
+						$this->value['margin-auto'] = true;
731
+						break;
732
+					}
733
+					$val = explode(' ', $val);
734
+					foreach ($val as $k => $v) {
735
+						$v = trim($v);
736
+						if ($v!='') {
737
+							$val[$k] = $v;
738
+						} else {
739
+							unset($val[$k]);
740
+						}
741
+					}
742
+					$val = array_values($val);
743
+					$this->_duplicateBorder($val);
744
+					$this->value['margin']['t'] = $this->convertToMM($val[0], 0);
745
+					$this->value['margin']['r'] = $this->convertToMM($val[1], 0);
746
+					$this->value['margin']['b'] = $this->convertToMM($val[2], 0);
747
+					$this->value['margin']['l'] = $this->convertToMM($val[3], 0);
748
+					break;
749
+
750
+				case 'margin-top':
751
+					$this->value['margin']['t'] = $this->convertToMM($val, 0);
752
+					break;
753
+
754
+				case 'margin-right':
755
+					$this->value['margin']['r'] = $this->convertToMM($val, 0);
756
+					break;
757
+
758
+				case 'margin-bottom':
759
+					$this->value['margin']['b'] = $this->convertToMM($val, 0);
760
+					break;
761
+
762
+				case 'margin-left':
763
+					$this->value['margin']['l'] = $this->convertToMM($val, 0);
764
+					break;
765
+
766
+				case 'border':
767
+					$val = $this->readBorder($val);
768
+					$this->value['border']['t'] = $val;
769
+					$this->value['border']['r'] = $val;
770
+					$this->value['border']['b'] = $val;
771
+					$this->value['border']['l'] = $val;
772
+					break;
773
+
774
+				case 'border-style':
775
+					$val = explode(' ', $val);
776
+					foreach ($val as $valK => $valV) {
777
+						if (!in_array($valV, array('solid', 'dotted', 'dashed'))) {
778
+							$val[$valK] = null;
779
+						}
780
+					}
781
+					$this->_duplicateBorder($val);
782
+					if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
+					if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
+					if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
+					if ($val[3]) $this->value['border']['l']['type'] = $val[3];
786
+					break;
787
+
788
+				case 'border-top-style':
789
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
790
+						$this->value['border']['t']['type'] = $val;
791
+					}
792
+					break;
793
+
794
+				case 'border-right-style':
795
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
796
+						$this->value['border']['r']['type'] = $val;
797
+					}
798
+					break;
799
+
800
+				case 'border-bottom-style':
801
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
802
+						$this->value['border']['b']['type'] = $val;
803
+					}
804
+					break;
805
+
806
+				case 'border-left-style':
807
+					if (in_array($val, array('solid', 'dotted', 'dashed')))
808
+						$this->value['border']['l']['type'] = $val;
809
+					break;
810
+
811
+				case 'border-color':
812
+					$res = false;
813
+					$val = preg_replace('/,[\s]+/', ',', $val);
814
+					$val = explode(' ', $val);
815
+					foreach ($val as $valK => $valV) {
816
+							$val[$valK] = $this->convertToColor($valV, $res);
817
+							if (!$res) {
818
+								$val[$valK] = null;
819
+							}
820
+					}
821
+					$this->_duplicateBorder($val);
822
+					if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
+					if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
+					if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
+					if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
826
+
827
+					break;
828
+
829
+				case 'border-top-color':
830
+					$res = false;
831
+					$val = $this->convertToColor($val, $res);
832
+					if ($res) $this->value['border']['t']['color'] = $val;
833
+					break;
834
+
835
+				case 'border-right-color':
836
+					$res = false;
837
+					$val = $this->convertToColor($val, $res);
838
+					if ($res) $this->value['border']['r']['color'] = $val;
839
+					break;
840
+
841
+				case 'border-bottom-color':
842
+					$res = false;
843
+					$val = $this->convertToColor($val, $res);
844
+					if ($res) $this->value['border']['b']['color'] = $val;
845
+					break;
846
+
847
+				case 'border-left-color':
848
+					$res = false;
849
+					$val = $this->convertToColor($val, $res);
850
+					if ($res) $this->value['border']['l']['color'] = $val;
851
+					break;
852
+
853
+				case 'border-width':
854
+					$val = explode(' ', $val);
855
+					foreach ($val as $valK => $valV) {
856
+							$val[$valK] = $this->convertToMM($valV, 0);
857
+					}
858
+					$this->_duplicateBorder($val);
859
+					if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
+					if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
+					if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
+					if ($val[3]) $this->value['border']['l']['width'] = $val[3];
863
+					break;
864
+
865
+				case 'border-top-width':
866
+					$val = $this->convertToMM($val, 0);
867
+					if ($val) $this->value['border']['t']['width'] = $val;
868
+					break;
869
+
870
+				case 'border-right-width':
871
+					$val = $this->convertToMM($val, 0);
872
+					if ($val) $this->value['border']['r']['width'] = $val;
873
+					break;
874
+
875
+				case 'border-bottom-width':
876
+					$val = $this->convertToMM($val, 0);
877
+					if ($val) $this->value['border']['b']['width'] = $val;
878
+					break;
879
+
880
+				case 'border-left-width':
881
+					$val = $this->convertToMM($val, 0);
882
+					if ($val) $this->value['border']['l']['width'] = $val;
883
+					break;
884
+
885
+				case 'border-collapse':
886
+					if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
887
+					break;
888
+
889
+				case 'border-radius':
890
+					$val = explode('/', $val);
891
+					if (count($val)>2) {
892
+						break;
893
+					}
894
+					$valH = $this->convertToRadius(trim($val[0]));
895
+					if (count($valH)<1 || count($valH)>4) {
896
+						break;
897
+					}
898
+					if (!isset($valH[1])) $valH[1] = $valH[0];
899
+					if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
+					if (!isset($valH[3])) $valH[3] = $valH[1];
901
+					if (isset($val[1])) {
902
+						$valV = $this->convertToRadius(trim($val[1]));
903
+						if (count($valV)<1 || count($valV)>4) {
904
+							break;
905
+						}
906
+						if (!isset($valV[1])) $valV[1] = $valV[0];
907
+						if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
+						if (!isset($valV[3])) $valV[3] = $valV[1];
909
+					} else {
910
+						$valV = $valH;
911
+					}
912
+					$this->value['border']['radius'] = array(
913
+								'tl' => array($valH[0], $valV[0]),
914
+								'tr' => array($valH[1], $valV[1]),
915
+								'br' => array($valH[2], $valV[2]),
916
+								'bl' => array($valH[3], $valV[3])
917
+							);
918
+					break;
919
+
920
+				case 'border-top-left-radius':
921
+					$val = $this->convertToRadius($val);
922
+					if (count($val)<1 || count($val)>2) {
923
+						break;
924
+					}
925
+					$this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
926
+					break;
927
+
928
+				case 'border-top-right-radius':
929
+					$val = $this->convertToRadius($val);
930
+					if (count($val)<1 || count($val)>2) {
931
+						break;
932
+					}
933
+					$this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
934
+					break;
935
+
936
+				case 'border-bottom-right-radius':
937
+					$val = $this->convertToRadius($val);
938
+					if (count($val)<1 || count($val)>2) {
939
+						break;
940
+					}
941
+					$this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
942
+					break;
943
+
944
+				case 'border-bottom-left-radius':
945
+					$val = $this->convertToRadius($val);
946
+					if (count($val)<1 || count($val)>2) {
947
+						break;
948
+					}
949
+					$this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
950
+					break;
951
+
952
+				case 'border-top':
953
+					$this->value['border']['t'] = $this->readBorder($val);
954
+					break;
955
+
956
+				case 'border-right':
957
+					$this->value['border']['r'] = $this->readBorder($val);
958
+					break;
959
+
960
+				case 'border-bottom':
961
+					$this->value['border']['b'] = $this->readBorder($val);
962
+					break;
963
+
964
+				case 'border-left':
965
+					$this->value['border']['l'] = $this->readBorder($val);
966
+					break;
967
+
968
+				case 'background-color':
969
+					$this->value['background']['color'] = $this->convertBackgroundColor($val);
970
+					break;
971
+
972
+				case 'background-image':
973
+					$this->value['background']['image'] = $this->convertBackgroundImage($val);
974
+					break;
975
+
976
+				case 'background-position':
977
+					$res = null;
978
+					$this->value['background']['position'] = $this->convertBackgroundPosition($val, $res);
979
+					break;
980
+
981
+				case 'background-repeat':
982
+					$this->value['background']['repeat'] = $this->convertBackgroundRepeat($val);
983
+					break;
984
+
985
+				case 'background':
986
+					$this->convertBackground($val, $this->value['background']);
987
+					break;
988
+
989
+				case 'position':
990
+					if ($val=='absolute')       $this->value['position'] = 'absolute';
991
+					else if ($val=='relative')  $this->value['position'] = 'relative';
992
+					else                        $this->value['position'] = null;
993
+					break;
994
+
995
+				case 'float':
996
+					if ($val=='left')           $this->value['float'] = 'left';
997
+					else if ($val=='right')     $this->value['float'] = 'right';
998
+					else                        $this->value['float'] = null;
999
+					break;
1000
+
1001
+				case 'display':
1002
+					if ($val=='inline')         $this->value['display'] = 'inline';
1003
+					else if ($val=='block')     $this->value['display'] = 'block';
1004
+					else if ($val=='none')      $this->value['display'] = 'none';
1005
+					else                        $this->value['display'] = null;
1006
+					break;
1007
+
1008
+				case 'top':
1009
+				case 'bottom':
1010
+				case 'left':
1011
+				case 'right':
1012
+					$this->value[$nom] = $val;
1013
+					break;
1014
+
1015
+				case 'list-style':
1016
+				case 'list-style-type':
1017
+				case 'list-style-image':
1018
+					if ($nom=='list-style') $nom = 'list-style-type';
1019
+					$this->value[$nom] = $val;
1020
+					break;
1021
+
1022
+				default:
1023
+					break;
1024
+			}
1025
+		}
1026
+
1027
+		$return = true;
1028
+
1029
+		// only for P tag
1030
+		if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
+		if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1032
+
1033
+		// force the text align to left, if asked by html2pdf
1034
+		if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035
+
1036
+		// correction on the width (quick box)
1037
+		if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1038
+			$this->value['width'] = $this->getLastWidth();
1039
+			$this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1040
+		} else {
1041
+			if ($correctWidth) {
1042
+				if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
+					$this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
+					$this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045
+				}
1046
+				if (in_array($tagName, array('th', 'td'))) {
1047
+					$this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048
+					$return = false;
1049
+				}
1050
+				if ($this->value['width']<0) $this->value['width']=0;
1051
+			} else {
1052
+				if ($this->value['width']) {
1053
+					if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
+					if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
+					if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
+					if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1057
+				}
1058
+			}
1059
+		}
1060
+		if ($this->value['height']) {
1061
+			if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
+			if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
+			if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
+			if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065
+		}
1066
+
1067
+		if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
+		if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
+		if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
+		if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071
+
1072
+		if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
+		if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1074
+
1075
+		return $return;
1076
+	}
1077
+
1078
+	 /**
1079
+	  * get the height of the current line
1080
+	  *
1081
+	  * @access public
1082
+	  * @return float $height in mm
1083
+	  */
1084
+	public function getLineHeight()
1085
+	{
1086
+		$val = $this->value['line-height'];
1087
+		if ($val=='normal') $val = '108%';
1088
+		return $this->convertToMM($val, $this->value['font-size']);
1089
+	}
1090
+
1091
+	 /**
1092
+	  * get the width of the parent
1093
+	  *
1094
+	  * @access public
1095
+	  * @param  boolean $mode true => adding padding and border
1096
+	  * @return float $width in mm
1097
+	  */
1098
+	public function getLastWidth($mode = false)
1099
+	{
1100
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1101
+			if ($this->table[$k]['width']) {
1102
+				$w = $this->table[$k]['width'];
1103
+				if ($mode) {
1104
+					$w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
+					$w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106
+				}
1107
+				return $w;
1108
+			}
1109
+		}
1110
+		return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin();
1111
+	}
1112
+
1113
+	 /**
1114
+	  * get the height of the parent
1115
+	  *
1116
+	  * @access public
1117
+	  * @param  boolean $mode true => adding padding and border
1118
+	  * @return float $height in mm
1119
+	  */
1120
+	public function getLastHeight($mode = false)
1121
+	{
1122
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1123
+			if ($this->table[$k]['height']) {
1124
+				$h = $this->table[$k]['height'];
1125
+				if ($mode) {
1126
+					$h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
+					$h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128
+				}
1129
+				return $h;
1130
+			}
1131
+		}
1132
+		return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin();
1133
+	}
1134
+
1135
+	/**
1136
+	 * get the value of the float property
1137
+	 *
1138
+	 * @access public
1139
+	 * @return $float left/right
1140
+	 */
1141
+	public function getFloat()
1142
+	{
1143
+		if ($this->value['float']=='left')    return 'left';
1144
+		if ($this->value['float']=='right')   return 'right';
1145
+		return null;
1146
+	}
1147
+
1148
+	/**
1149
+	 * get the last value for a specific key
1150
+	 *
1151
+	 * @access public
1152
+	 * @param  string $key
1153
+	 * @return mixed
1154
+	 */
1155
+	public function getLastValue($key)
1156
+	{
1157
+		$nb = count($this->table);
1158
+		if ($nb>0) {
1159
+			return $this->table[$nb-1][$key];
1160
+		} else {
1161
+			return null;
1162
+		}
1163
+	}
1164
+
1165
+	/**
1166
+	 * get the last absolute X
1167
+	 *
1168
+	 * @access protected
1169
+	 * @return float $x
1170
+	 */
1171
+	protected function _getLastAbsoluteX()
1172
+	{
1173
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1174
+			if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175
+		}
1176
+		return $this->_pdf->getlMargin();
1177
+	}
1178
+
1179
+	/**
1180
+	 * get the last absolute Y
1181
+	 *
1182
+	 * @access protected
1183
+	 * @return float $y
1184
+	 */
1185
+	protected function _getLastAbsoluteY()
1186
+	{
1187
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1188
+			if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189
+		}
1190
+		return $this->_pdf->gettMargin();
1191
+	}
1192
+
1193
+	/**
1194
+	 * get the CSS properties of the current tag
1195
+	 *
1196
+	 * @access protected
1197
+	 * @return array $styles
1198
+	 */
1199
+	protected function _getFromCSS()
1200
+	{
1201
+		// styles to apply
1202
+		$styles = array();
1203
+
1204
+		// list of the selectors to get in the CSS files
1205
+		$getit  = array();
1206
+
1207
+		// get the list of the selectors of each tags
1208
+		$lst = array();
1209
+		$lst[] = $this->value['id_lst'];
1210
+		for ($i=count($this->table)-1; $i>=0; $i--) {
1211
+			$lst[] = $this->table[$i]['id_lst'];
1212
+		}
1213
+
1214
+		// foreach selectors in the CSS files, verify if it match with the list of selectors
1215
+		foreach ($this->cssKeys as $key => $num) {
1216
+			if ($this->_getReccursiveStyle($key, $lst)) {
1217
+				$getit[$key] = $num;
1218
+			}
1219
+		}
1220
+
1221
+		// if we have selectors
1222
+		if (count($getit)) {
1223
+			// get them, but in the definition order, because of priority
1224
+			asort($getit);
1225
+			foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1226
+		}
1227
+
1228
+		return $styles;
1229
+	}
1230
+
1231
+	/**
1232
+	 * identify if the selector $key match with the list of tag selectors
1233
+	 *
1234
+	 * @access protected
1235
+	 * @param  string   $key CSS selector to analyse
1236
+	 * @param  array    $lst list of the selectors of each tags
1237
+	 * @param  string   $next next step of parsing the selector
1238
+	 * @return boolean
1239
+	 */
1240
+	protected function _getReccursiveStyle($key, $lst, $next = null)
1241
+	{
1242
+		// if next step
1243
+		if ($next!==null) {
1244
+			// we remove this step
1245
+			if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246
+			array_shift($lst);
1247
+
1248
+			// if no more step to identify => return false
1249
+			if (!count($lst)) {
1250
+				return false;
1251
+			}
1252
+		}
1253
+
1254
+		// for each selector of the current step
1255
+		foreach ($lst[0] as $name) {
1256
+			// if selector = key => ok
1257
+			if ($key==$name) {
1258
+				return true;
1259
+			}
1260
+
1261
+			// if the end of the key = the selector and the next step is ok => ok
1262
+			if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263
+				return true;
1264
+			}
1265
+		}
1266
+
1267
+		// if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
+		if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1269
+			return true;
1270
+		}
1271
+
1272
+		// no corresponding found
1273
+		return false;
1274
+	}
1275
+
1276
+	/**
1277
+	 * Analyse a border
1278
+	 *
1279
+	 * @access  public
1280
+	 * @param   string $css css border properties
1281
+	 * @return  array  border properties
1282
+	 */
1283
+	public function readBorder($css)
1284
+	{
1285
+		// border none
1286
+		$none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
1287
+
1288
+		// default value
1289
+		$type  = 'solid';
1290
+		$width = $this->convertToMM('1pt');
1291
+		$color = array(0, 0, 0);
1292
+
1293
+		// clean up the values
1294
+		$css = explode(' ', $css);
1295
+		foreach ($css as $k => $v) {
1296
+			$v = trim($v);
1297
+			if ($v) $css[$k] = $v;
1298
+			else    unset($css[$k]);
1299
+		}
1300
+		$css = array_values($css);
1301
+
1302
+		// read the values
1303
+		$res = null;
1304
+		foreach ($css as $value) {
1305
+
1306
+			// if no border => return none
1307
+			if ($value=='none' || $value=='hidden') {
1308
+				return $none;
1309
+			}
1310
+
1311
+			// try to convert the value as a distance
1312
+			$tmp = $this->convertToMM($value);
1313
+
1314
+			// if the convert is ok => it is a width
1315
+			if ($tmp!==null) {
1316
+				$width = $tmp;
1317
+			// else, it could be the type
1318
+			} else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
1319
+				$type = $value;
1320
+			// else, it could be the color
1321
+			} else {
1322
+				$tmp = $this->convertToColor($value, $res);
1323
+				if ($res) $color = $tmp;
1324
+			}
1325
+		}
1326
+
1327
+		// if no witdh => return none
1328
+		if (!$width) return $none;
1329
+
1330
+		// return the border properties
1331
+		return array('type' => $type, 'width' => $width, 'color' => $color);
1332
+	}
1333
+
1334
+	/**
1335
+	 * duplicate the borders if needed
1336
+	 *
1337
+	 * @access protected
1338
+	 * @param  &array $val
1339
+	 */
1340
+	protected function _duplicateBorder(&$val)
1341
+	{
1342
+		// 1 value => L => RTB
1343
+		if (count($val)==1) {
1344
+			$val[1] = $val[0];
1345
+			$val[2] = $val[0];
1346
+			$val[3] = $val[0];
1347
+		// 2 values => L => R & T => B
1348
+		} else if (count($val)==2) {
1349
+			$val[2] = $val[0];
1350
+			$val[3] = $val[1];
1351
+		// 3 values => T => B
1352
+		} else if (count($val)==3) {
1353
+			$val[3] = $val[1];
1354
+		}
1355
+	}
1356
+
1357
+	/**
1358
+	 * Analyse a background
1359
+	 *
1360
+	 * @access public
1361
+	 * @param  string $css css background properties
1362
+	 * @param  &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties)
1363
+	 */
1364
+	public function convertBackground($css, &$value)
1365
+	{
1366
+		// is there a image ?
1367
+		$text = '/url\(([^)]*)\)/isU';
1368
+		if (preg_match($text, $css, $match)) {
1369
+			// get the image
1370
+			$value['image'] = $this->convertBackgroundImage($match[0]);
1371
+
1372
+			// remove if from the css properties
1373
+			$css = preg_replace($text, '', $css);
1374
+			$css = preg_replace('/[\s]+/', ' ', $css);
1375
+		}
1376
+
1377
+		// protect some spaces
1378
+		$css = preg_replace('/,[\s]+/', ',', $css);
1379
+
1380
+		// explode the values
1381
+		$css = explode(' ', $css);
1382
+
1383
+		// background position to parse
1384
+		$pos = '';
1385
+
1386
+		// foreach value
1387
+		foreach ($css as $val) {
1388
+			// try to parse the value as a color
1389
+			$ok = false;
1390
+			$color = $this->convertToColor($val, $ok);
1391
+
1392
+			// if ok => it is a color
1393
+			if ($ok) {
1394
+				$value['color'] = $color;
1395
+			// else if transparent => no coloàr
1396
+			} else if ($val=='transparent') {
1397
+				$value['color'] = null;
1398
+			// else
1399
+			} else {
1400
+				// try to parse the value as a repeat
1401
+				$repeat = $this->convertBackgroundRepeat($val);
1402
+
1403
+				// if ok => it is repeat
1404
+				if ($repeat) {
1405
+					$value['repeat'] = $repeat;
1406
+				// else => it could only be a position
1407
+				} else {
1408
+					$pos.= ($pos ? ' ' : '').$val;
1409
+				}
1410
+			}
1411
+		}
1412
+
1413
+		// if we have a position to parse
1414
+		if ($pos) {
1415
+			// try to read it
1416
+			$pos = $this->convertBackgroundPosition($pos, $ok);
1417
+			if ($ok) $value['position'] = $pos;
1418
+		}
1419
+	}
1420
+
1421
+	/**
1422
+	 * parse a background color
1423
+	 *
1424
+	 * @access public
1425
+	 * @param  string $css
1426
+	 * @return string $value
1427
+	 */
1428
+	public function convertBackgroundColor($css)
1429
+	{
1430
+		$res = null;
1431
+		if ($css=='transparent') return null;
1432
+		else                     return $this->convertToColor($css, $res);
1433
+	}
1434
+
1435
+	/**
1436
+	 * parse a background image
1437
+	 *
1438
+	 * @access public
1439
+	 * @param  string $css
1440
+	 * @return string $value
1441
+	 */
1442
+	public function convertBackgroundImage($css)
1443
+	{
1444
+		if ($css=='none')
1445
+			return null;
1446
+		else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
+			return $match[1];
1448
+		else
1449
+			return null;
1450
+	}
1451
+
1452
+	/**
1453
+	 * parse a background position
1454
+	 *
1455
+	 * @access public
1456
+	 * @param  string $css
1457
+	 * @param  &boolean $res flag if conver is ok or not
1458
+	 * @return array ($x, $y)
1459
+	 */
1460
+	public function convertBackgroundPosition($css, &$res)
1461
+	{
1462
+		// init the res
1463
+		$res = false;
1464
+
1465
+		// explode the value
1466
+		$css = explode(' ', $css);
1467
+
1468
+		// we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
+		if (count($css)<2) {
1470
+			if (!$css[0]) return null;
1471
+			$css[1] = 'center';
1472
+		}
1473
+		if (count($css)>2) return null;
1474
+
1475
+		// prepare the values
1476
+		$x = 0;
1477
+		$y = 0;
1478
+		$res = true;
1479
+
1480
+		// convert the first value
1481
+		if ($css[0]=='left')        $x = '0%';
1482
+		else if ($css[0]=='center') $x = '50%';
1483
+		else if ($css[0]=='right')  $x = '100%';
1484
+		else if ($css[0]=='top')    $y = '0%';
1485
+		else if ($css[0]=='bottom') $y = '100%';
1486
+		else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
+		else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
+		else $res = false;
1489
+
1490
+		// convert the second value
1491
+		if ($css[1]=='left')        $x = '0%';
1492
+		else if ($css[1]=='right')  $x = '100%';
1493
+		else if ($css[1]=='top')    $y = '0%';
1494
+		else if ($css[1]=='center') $y = '50%';
1495
+		else if ($css[1]=='bottom') $y = '100%';
1496
+		else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
+		else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
+		else $res = false;
1499
+
1500
+		// return the values
1501
+		return array($x, $y);
1502
+	}
1503
+
1504
+	/**
1505
+	 * parse a background repeat
1506
+	 *
1507
+	 * @access public
1508
+	 * @param  string $css
1509
+	 * @return string $value
1510
+	 */
1511
+	public function convertBackgroundRepeat($css)
1512
+	{
1513
+		switch($css)
1514
+		{
1515
+			case 'repeat':
1516
+				return array(true, true);
1517
+			case 'repeat-x':
1518
+				return array(true, false);
1519
+			case 'repeat-y':
1520
+				return array(false, true);
1521
+			case 'no-repeat':
1522
+				return array(false, false);
1523
+		}
1524
+		return null;
1525
+	}
1526
+
1527
+	 /**
1528
+	  * convert a distance to mm
1529
+	  *
1530
+	  * @access public
1531
+	  * @param  string $css distance to convert
1532
+	  * @param  float  $old parent distance
1533
+	  * @return float  $value
1534
+	  */
1535
+	public function convertToMM($css, $old=0.)
1536
+	{
1537
+		$css = trim($css);
1538
+		if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
+		if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
+		else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
+		else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
+		else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
+		else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
+		else                                              $css = null;
1545
+
1546
+		return $css;
1547
+	}
1548
+
1549
+	/**
1550
+	 * convert a css radius
1551
+	 *
1552
+	 * @access public
1553
+	 * @param  string $css
1554
+	 * @return float  $value
1555
+	 */
1556
+	public function convertToRadius($css)
1557
+	{
1558
+		// explode the value
1559
+		$css = explode(' ', $css);
1560
+
1561
+		foreach ($css as $k => $v) {
1562
+			$v = trim($v);
1563
+			if ($v) {
1564
+				$v = $this->convertToMM($v, 0);
1565
+				if ($v!==null) {
1566
+					$css[$k] = $v;
1567
+				} else {
1568
+					unset($css[$k]);
1569
+				}
1570
+			} else {
1571
+				unset($css[$k]);
1572
+			}
1573
+		}
1574
+
1575
+		return array_values($css);
1576
+	}
1577
+
1578
+	/**
1579
+	 * convert a css color
1580
+	 *
1581
+	 * @access public
1582
+	 * @param  string $css
1583
+	 * @param  &boolean $res
1584
+	 * @return array (r,g, b)
1585
+	 */
1586
+	public function convertToColor($css, &$res)
1587
+	{
1588
+		// prepare the value
1589
+		$css = trim($css);
1590
+		$res = true;
1591
+
1592
+		// if transparent => return null
1593
+		if (strtolower($css)=='transparent') return array(null, null, null);
1594
+
1595
+		// HTML color
1596
+		if (isset($this->_htmlColor[strtolower($css)])) {
1597
+			$css = $this->_htmlColor[strtolower($css)];
1598
+			$r = floatVal(hexdec(substr($css, 0, 2)));
1599
+			$v = floatVal(hexdec(substr($css, 2, 2)));
1600
+			$b = floatVal(hexdec(substr($css, 4, 2)));
1601
+			return array($r, $v, $b);
1602
+		}
1603
+
1604
+		// like #FFFFFF
1605
+		if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) {
1606
+			$r = floatVal(hexdec(substr($css, 1, 2)));
1607
+			$v = floatVal(hexdec(substr($css, 3, 2)));
1608
+			$b = floatVal(hexdec(substr($css, 5, 2)));
1609
+			return array($r, $v, $b);
1610
+		}
1611
+
1612
+		// like #FFF
1613
+		if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
+			$r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
+			$v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
+			$b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1617
+			return array($r, $v, $b);
1618
+		}
1619
+
1620
+		// like rgb(100, 100, 100)
1621
+		if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1622
+			$r = $this->_convertSubColor($match[1]);
1623
+			$v = $this->_convertSubColor($match[2]);
1624
+			$b = $this->_convertSubColor($match[3]);
1625
+			return array($r*255., $v*255., $b*255.);
1626
+		}
1627
+
1628
+		// like cmyk(100, 100, 100, 100)
1629
+		if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1630
+			$c = $this->_convertSubColor($match[1]);
1631
+			$m = $this->_convertSubColor($match[2]);
1632
+			$y = $this->_convertSubColor($match[3]);
1633
+			$k = $this->_convertSubColor($match[4]);
1634
+			return array($c*100., $m*100., $y*100., $k*100.);
1635
+		}
1636
+
1637
+		$res = false;
1638
+		return array(0., 0., 0.);
1639
+	}
1640
+
1641
+	/**
1642
+	 * color value to convert
1643
+	 *
1644
+	 * @access protected
1645
+	 * @param  string $c
1646
+	 * @return float $c 0.->1.
1647
+	 */
1648
+	protected function _convertSubColor($c)
1649
+	{
1650
+		if (substr($c, -1)=='%') {
1651
+			$c = floatVal(substr($c, 0, -1))/100.;
1652
+		} else {
1653
+			$c = floatVal($c);
1654
+			if ($c>1) $c = $c/255.;
1655
+		}
1656
+
1657
+		return $c;
1658
+	}
1659
+
1660
+	/**
1661
+	 * read a css content
1662
+	 *
1663
+	 * @access protected
1664
+	 * @param  &string $code
1665
+	 */
1666
+	protected function _analyseStyle(&$code)
1667
+	{
1668
+		// clean the spaces
1669
+		$code = preg_replace('/[\s]+/', ' ', $code);
1670
+
1671
+		// remove the comments
1672
+		$code = preg_replace('/\/\*.*?\*\//s', '', $code);
1673
+
1674
+		// split each CSS code "selector { value }"
1675
+		preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676
+
1677
+		// for each CSS code
1678
+		for ($k=0; $k<count($match[0]); $k++) {
1679
+
1680
+			// selectors
1681
+			$names = strtolower(trim($match[1][$k]));
1682
+
1683
+			// css style
1684
+			$styles = trim($match[2][$k]);
1685
+
1686
+			// explode each value
1687
+			$styles = explode(';', $styles);
1688
+
1689
+			// parse each value
1690
+			$css = array();
1691
+			foreach ($styles as $style) {
1692
+				$tmp = explode(':', $style);
1693
+				if (count($tmp)>1) {
1694
+					$cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695
+					$css[trim(strtolower($cod))] = trim($tmp);
1696
+				}
1697
+			}
1698
+
1699
+			// explode the names
1700
+			$names = explode(',', $names);
1701
+
1702
+			// save the values for each names
1703
+			foreach ($names as $name) {
1704
+				// clean the name
1705
+				$name = trim($name);
1706
+
1707
+				// if a selector with somethink lige :hover => continue
1708
+				if (strpos($name, ':')!==false) continue;
1709
+
1710
+				// save the value
1711
+				if (!isset($this->css[$name]))
1712
+					$this->css[$name] = $css;
1713
+				else
1714
+					$this->css[$name] = array_merge($this->css[$name], $css);
1715
+
1716
+			}
1717
+		}
1718
+
1719
+		// get he list of the keys
1720
+		$this->cssKeys = array_flip(array_keys($this->css));
1721
+	}
1722
+
1723
+	/**
1724
+	 * Extract the css files from a html code
1725
+	 *
1726
+	 * @access public
1727
+	 * @param  string   &$html
1728
+	 */
1729
+	public function readStyle(&$html)
1730
+	{
1731
+		// the CSS content
1732
+		$style = ' ';
1733
+
1734
+		// extract the link tags, and remove them in the html code
1735
+		preg_match_all('/<link([^>]*)>/isU', $html, $match);
1736
+		$html = preg_replace('/<link[^>]*>/isU', '', $html);
1737
+		$html = preg_replace('/<\/link[^>]*>/isU', '', $html);
1738
+
1739
+		// analyse each link tag
1740
+		foreach ($match[1] as $code) {
1741
+			$tmp = array();
1742
+
1743
+			// read the attributes name=value
1744
+			$prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
+			preg_match_all('/'.$prop.'/is', $code, $match);
1746
+			for ($k=0; $k<count($match[0]); $k++) {
1747
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748
+			}
1749
+
1750
+			// read the attributes name="value"
1751
+			$prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
+			preg_match_all('/'.$prop.'/is', $code, $match);
1753
+			for ($k=0; $k<count($match[0]); $k++) {
1754
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755
+			}
1756
+
1757
+			// read the attributes name='value'
1758
+			$prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
+			preg_match_all('/'.$prop.'/is', $code, $match);
1760
+			for ($k=0; $k<count($match[0]); $k++) {
1761
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762
+			}
1763
+
1764
+			// if type text/css => we keep it
1765
+			if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1766
+
1767
+				// get the href
1768
+				$url = $tmp['href'];
1769
+
1770
+				// get the content of the css file
1771
+				$content = @file_get_contents($url);
1772
+
1773
+				// if "http://" in the url
1774
+				if (strpos($url, 'http://')!==false) {
1775
+
1776
+					// get the domain "http://xxx/"
1777
+					$url = str_replace('http://', '', $url);
1778
+					$url = explode('/', $url);
1779
+					$urlMain = 'http://'.$url[0].'/';
1780
+
1781
+					// get the absolute url of the path
1782
+					$urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1783
+
1784
+					// adapt the url in the css content
1785
+					$content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
+					$content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1787
+				} else {
1788 1788
 // @TODO correction on url in absolute on a local css content
1789
-                    // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790
-                }
1791
-
1792
-                // add to the CSS content
1793
-                $style.= $content."\n";
1794
-            }
1795
-        }
1796
-
1797
-        // extract the style tags des tags style, and remove them in the html code
1798
-        preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
1799
-        $html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html);
1800
-
1801
-        // analyse each style tags
1802
-        foreach ($match[1] as $code) {
1803
-            // add to the CSS content
1804
-            $code = str_replace('<!--', '', $code);
1805
-            $code = str_replace('-->', '', $code);
1806
-            $style.= $code."\n";
1807
-        }
1808
-
1809
-        //analyse the css content
1810
-        $this->_analyseStyle($style);
1811
-    }
1789
+					// $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790
+				}
1791
+
1792
+				// add to the CSS content
1793
+				$style.= $content."\n";
1794
+			}
1795
+		}
1796
+
1797
+		// extract the style tags des tags style, and remove them in the html code
1798
+		preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
1799
+		$html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html);
1800
+
1801
+		// analyse each style tags
1802
+		foreach ($match[1] as $code) {
1803
+			// add to the CSS content
1804
+			$code = str_replace('<!--', '', $code);
1805
+			$code = str_replace('-->', '', $code);
1806
+			$style.= $code."\n";
1807
+		}
1808
+
1809
+		//analyse the css content
1810
+		$this->_analyseStyle($style);
1811
+	}
1812 1812
 }
1813 1813
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - parsingCss class
4 4
  *
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
     protected $_pdf         = null;
19 19
 
20 20
     protected $_htmlColor   = array(); // list of the HTML colors
21
-    protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
-    protected $_defaultFont = null;    // default font to use if the asked font does not exist
21
+    protected $_onlyLeft    = false; // flag if we are in a sub html => only "text-align:left" is used
22
+    protected $_defaultFont = null; // default font to use if the asked font does not exist
23 23
 
24 24
     public    $value        = array(); // current values
25 25
     public    $css          = array(); // css values
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getOldValues()
70 70
     {
71
-        return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
71
+        return isset($this->table[count($this->table) - 1]) ? $this->table[count($this->table) - 1] : $this->value;
72 72
     }
73 73
 
74 74
     /**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     protected function _init()
95 95
     {
96 96
         // get the Web Colors from TCPDF
97
-        require(K_PATH_MAIN.'htmlcolors.php');
97
+        require(K_PATH_MAIN . 'htmlcolors.php');
98 98
         $this->_htmlColor = $webcolor;
99 99
 
100 100
         // init the Style
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function initStyle()
115 115
     {
116
-        $this->value['id_tag']       = 'body';        // tag name
117
-        $this->value['id_name']          = null;         // tag - attribute name
118
-        $this->value['id_id']            = null;         // tag - attribute id
119
-        $this->value['id_class']         = null;         // tag - attribute class
120
-        $this->value['id_lst']           = array('*');   // tag - list of legacy
121
-        $this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
-        $this->value['mini-decal']       = 0;            // specific position report for sup, sub
116
+        $this->value['id_tag'] = 'body'; // tag name
117
+        $this->value['id_name']          = null; // tag - attribute name
118
+        $this->value['id_id']            = null; // tag - attribute id
119
+        $this->value['id_class']         = null; // tag - attribute class
120
+        $this->value['id_lst']           = array('*'); // tag - list of legacy
121
+        $this->value['mini-size']        = 1.; // specific size report for sup, sub
122
+        $this->value['mini-decal']       = 0; // specific position report for sup, sub
123 123
         $this->value['font-family']      = 'Arial';
124 124
         $this->value['font-bold']        = false;
125 125
         $this->value['font-italic']      = false;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
         // specific values for some tags
214 214
         if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
-            $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
215
+            $this->value['margin'] = array('t'=>0, 'r'=>0, 'b'=>0, 'l'=>0);
216 216
         }
217 217
 
218 218
         if (in_array($tagName, array('input', 'select', 'textarea'))) {
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
             $this->value['border']['l'] = null;
223 223
         }
224 224
 
225
-        if ($tagName=='p') {
225
+        if ($tagName == 'p') {
226 226
             $this->value['margin']['t'] = null;
227 227
             $this->value['margin']['b'] = null;
228 228
         }
229
-        if ($tagName=='blockquote') {
229
+        if ($tagName == 'blockquote') {
230 230
             $this->value['margin']['t'] = 3;
231 231
             $this->value['margin']['r'] = 3;
232 232
             $this->value['margin']['b'] = 3;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             );
276 276
         }
277 277
 
278
-        if ($tagName=='hr') {
278
+        if ($tagName == 'hr') {
279 279
             $this->value['border'] = array(
280 280
                 't' => $border,
281 281
                 'r' => $border,
@@ -305,40 +305,40 @@  discard block
 block discarded – undo
305 305
     {
306 306
         $family = strtolower($this->value['font-family']);
307 307
 
308
-        $b = ($this->value['font-bold']        ? 'B' : '');
309
-        $i = ($this->value['font-italic']      ? 'I' : '');
310
-        $u = ($this->value['font-underline']   ? 'U' : '');
308
+        $b = ($this->value['font-bold'] ? 'B' : '');
309
+        $i = ($this->value['font-italic'] ? 'I' : '');
310
+        $u = ($this->value['font-underline'] ? 'U' : '');
311 311
         $d = ($this->value['font-linethrough'] ? 'D' : '');
312
-        $o = ($this->value['font-overline']    ? 'O' : '');
312
+        $o = ($this->value['font-overline'] ? 'O' : '');
313 313
 
314 314
         // font style
315
-        $style = $b.$i;
315
+        $style = $b . $i;
316 316
 
317 317
         if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
318
+            if ($family == 'arial')
319
+                $family = 'helvetica';
320
+            elseif ($family == 'symbol' || $family == 'zapfdingbats')
321
+                $style = '';
322 322
 
323
-            $fontkey = $family.$style;
323
+            $fontkey = $family . $style;
324 324
             if (!$this->_pdf->isLoadedFont($fontkey))
325 325
                 $family = $this->_defaultFont;
326 326
         }
327 327
 
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
328
+        if ($family == 'arial')
329
+            $family = 'helvetica';
330
+        elseif ($family == 'symbol' || $family == 'zapfdingbats')
331
+            $style = '';
332 332
 
333 333
         // complete style
334
-        $style.= $u.$d.$o;
334
+        $style .= $u . $d . $o;
335 335
 
336 336
         // size : mm => pt
337 337
         $size = $this->value['font-size'];
338 338
         $size = 72 * $size / 25.4;
339 339
 
340 340
         // apply the font
341
-        $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
341
+        $this->_pdf->SetFont($family, $style, $this->value['mini-size'] * $size);
342 342
         $this->_pdf->setTextColorArray($this->value['color']);
343 343
         if ($this->value['background']['color'])
344 344
             $this->_pdf->setFillColorArray($this->value['background']['color']);
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      */
376 376
     public function restorePosition()
377 377
     {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
378
+        if ($this->value['y'] == $this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379 379
     }
380 380
 
381 381
      /**
@@ -393,35 +393,35 @@  discard block
 block discarded – undo
393 393
         $this->value['xc'] = $currentX;
394 394
         $this->value['yc'] = $currentY;
395 395
 
396
-        if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
-            if ($this->value['right']!==null) {
396
+        if ($this->value['position'] == 'relative' || $this->value['position'] == 'absolute') {
397
+            if ($this->value['right'] !== null) {
398 398
                 $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
399
+                if ($this->value['margin']['r']) $x -= $this->value['margin']['r'];
400 400
             } else {
401 401
                 $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
402
+                if ($this->value['margin']['l']) $x += $this->value['margin']['l'];
403 403
             }
404 404
 
405
-            if ($this->value['bottom']!==null) {
405
+            if ($this->value['bottom'] !== null) {
406 406
                 $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
407
+                if ($this->value['margin']['b']) $y -= $this->value['margin']['b'];
408 408
             } else {
409 409
                 $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
410
+                if ($this->value['margin']['t']) $y += $this->value['margin']['t'];
411 411
             }
412 412
 
413
-            if ($this->value['position']=='relative') {
413
+            if ($this->value['position'] == 'relative') {
414 414
                 $this->value['x'] = $currentX + $x;
415 415
                 $this->value['y'] = $currentY + $y;
416 416
             } else {
417
-                $this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
-                $this->value['y'] = $this->_getLastAbsoluteY()+$y;
417
+                $this->value['x'] = $this->_getLastAbsoluteX() + $x;
418
+                $this->value['y'] = $this->_getLastAbsoluteY() + $y;
419 419
             }
420 420
         } else {
421 421
             $this->value['x'] = $currentX;
422 422
             $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
423
+            if ($this->value['margin']['l']) $this->value['x'] += $this->value['margin']['l'];
424
+            if ($this->value['margin']['t']) $this->value['y'] += $this->value['margin']['t'];
425 425
         }
426 426
 
427 427
         // save the new position
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     {
479 479
         // prepare
480 480
         $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
481
+        $id   = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id)   $id   = null;
482 482
         $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483 483
 
484 484
         // read the class attribute
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
 
510 510
         if (count($class)) {
511 511
             foreach ($class as $v) {
512
-                $this->value['id_lst'][] = '*.'.$v;
513
-                $this->value['id_lst'][] = '.'.$v;
514
-                $this->value['id_lst'][] = $tagName.'.'.$v;
512
+                $this->value['id_lst'][] = '*.' . $v;
513
+                $this->value['id_lst'][] = '.' . $v;
514
+                $this->value['id_lst'][] = $tagName . '.' . $v;
515 515
             }
516 516
         }
517 517
         if ($id) {
518
-            $this->value['id_lst'][] = '*#'.$id;
519
-            $this->value['id_lst'][] = '#'.$id;
520
-            $this->value['id_lst'][] = $tagName.'#'.$id;
518
+            $this->value['id_lst'][] = '*#' . $id;
519
+            $this->value['id_lst'][] = '#' . $id;
520
+            $this->value['id_lst'][] = $tagName . '#' . $id;
521 521
         }
522 522
 
523 523
         // CSS style
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530 530
         if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531 531
         if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
532
+        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1. * $styles['fill-opacity'];
533 533
 
534 534
         return $this->value['svg'];
535 535
     }
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
     {
547 547
         // prepare the informations
548 548
         $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
549
+        $id   = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id)   $id   = null;
550
+        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
551 551
 
552 552
         // get the class names to use
553 553
         $class = array();
@@ -568,15 +568,15 @@  discard block
 block discarded – undo
568 568
         $this->value['id_lst'][] = $tagName;
569 569
         if (count($class)) {
570 570
             foreach ($class as $v) {
571
-                $this->value['id_lst'][] = '*.'.$v;
572
-                $this->value['id_lst'][] = '.'.$v;
573
-                $this->value['id_lst'][] = $tagName.'.'.$v;
571
+                $this->value['id_lst'][] = '*.' . $v;
572
+                $this->value['id_lst'][] = '.' . $v;
573
+                $this->value['id_lst'][] = $tagName . '.' . $v;
574 574
             }
575 575
         }
576 576
         if ($id) {
577
-            $this->value['id_lst'][] = '*#'.$id;
578
-            $this->value['id_lst'][] = '#'.$id;
579
-            $this->value['id_lst'][] = $tagName.'#'.$id;
577
+            $this->value['id_lst'][] = '*#' . $id;
578
+            $this->value['id_lst'][] = '#' . $id;
579
+            $this->value['id_lst'][] = $tagName . '#' . $id;
580 580
         }
581 581
 
582 582
         // get the css styles from class
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         if ($legacy) {
594 594
             foreach ($legacy as $legacyName => $legacyValue) {
595 595
                 if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
596
+                    foreach ($legacyValue as $legacy2Name => $legacy2Value)
597 597
                         $this->value[$legacyName][$legacy2Name] = $legacy2Value;
598 598
                 } else {
599 599
                     $this->value[$legacyName] = $legacyValue;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
         // read all the css styles
609 609
         foreach ($styles as $nom => $val) {
610
-            switch($nom)
610
+            switch ($nom)
611 611
             {
612 612
                 case 'font-family':
613 613
                     $val = explode(',', $val);
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
                     break;
617 617
 
618 618
                 case 'font-weight':
619
-                    $this->value['font-bold'] = ($val=='bold');
619
+                    $this->value['font-bold'] = ($val == 'bold');
620 620
                     break;
621 621
 
622 622
                 case 'font-style':
623
-                    $this->value['font-italic'] = ($val=='italic');
623
+                    $this->value['font-italic'] = ($val == 'italic');
624 624
                     break;
625 625
 
626 626
                 case 'text-decoration':
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
                 case 'text-transform':
638 638
                     if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
-                    $this->value['text-transform']  = $val;
639
+                    $this->value['text-transform'] = $val;
640 640
                     break;
641 641
 
642 642
                 case 'font-size':
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
                 case 'color':
648 648
                     $res = null;
649 649
                     $this->value['color'] = $this->convertToColor($val, $res);
650
-                    if ($tagName=='hr') {
650
+                    if ($tagName == 'hr') {
651 651
                         $this->value['border']['l']['color'] = $this->value['color'];
652 652
                         $this->value['border']['t']['color'] = $this->value['color'];
653 653
                         $this->value['border']['r']['color'] = $this->value['color'];
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 
668 668
                 case 'width':
669 669
                     $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
670
+                    if ($this->value['width'] && substr($val, -1) == '%') $correctWidth = true;
671 671
                     $noWidth = false;
672 672
                     break;
673 673
 
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
                     break;
677 677
 
678 678
                 case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
679
+                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val * 100) . '%';
680 680
                     $this->value['line-height'] = $val;
681 681
                     break;
682 682
 
683 683
                 case 'rotate':
684 684
                     if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
685
+                    if ($val < 0) $val += 360;
686 686
                     $this->value['rotate'] = $val;
687 687
                     break;
688 688
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                     $val = explode(' ', $val);
696 696
                     foreach ($val as $k => $v) {
697 697
                         $v = trim($v);
698
-                        if ($v!='') {
698
+                        if ($v != '') {
699 699
                             $val[$k] = $v;
700 700
                         } else {
701 701
                             unset($val[$k]);
@@ -726,14 +726,14 @@  discard block
 block discarded – undo
726 726
                     break;
727 727
 
728 728
                 case 'margin':
729
-                    if ($val=='auto') {
729
+                    if ($val == 'auto') {
730 730
                         $this->value['margin-auto'] = true;
731 731
                         break;
732 732
                     }
733 733
                     $val = explode(' ', $val);
734 734
                     foreach ($val as $k => $v) {
735 735
                         $v = trim($v);
736
-                        if ($v!='') {
736
+                        if ($v != '') {
737 737
                             $val[$k] = $v;
738 738
                         } else {
739 739
                             unset($val[$k]);
@@ -883,16 +883,16 @@  discard block
 block discarded – undo
883 883
                     break;
884 884
 
885 885
                 case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
886
+                    if ($tagName == 'table') $this->value['border']['collapse'] = ($val == 'collapse');
887 887
                     break;
888 888
 
889 889
                 case 'border-radius':
890 890
                     $val = explode('/', $val);
891
-                    if (count($val)>2) {
891
+                    if (count($val) > 2) {
892 892
                         break;
893 893
                     }
894 894
                     $valH = $this->convertToRadius(trim($val[0]));
895
-                    if (count($valH)<1 || count($valH)>4) {
895
+                    if (count($valH) < 1 || count($valH) > 4) {
896 896
                         break;
897 897
                     }
898 898
                     if (!isset($valH[1])) $valH[1] = $valH[0];
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
                     if (!isset($valH[3])) $valH[3] = $valH[1];
901 901
                     if (isset($val[1])) {
902 902
                         $valV = $this->convertToRadius(trim($val[1]));
903
-                        if (count($valV)<1 || count($valV)>4) {
903
+                        if (count($valV) < 1 || count($valV) > 4) {
904 904
                             break;
905 905
                         }
906 906
                         if (!isset($valV[1])) $valV[1] = $valV[0];
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 
920 920
                 case 'border-top-left-radius':
921 921
                     $val = $this->convertToRadius($val);
922
-                    if (count($val)<1 || count($val)>2) {
922
+                    if (count($val) < 1 || count($val) > 2) {
923 923
                         break;
924 924
                     }
925 925
                     $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
                 case 'border-top-right-radius':
929 929
                     $val = $this->convertToRadius($val);
930
-                    if (count($val)<1 || count($val)>2) {
930
+                    if (count($val) < 1 || count($val) > 2) {
931 931
                         break;
932 932
                     }
933 933
                     $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 
936 936
                 case 'border-bottom-right-radius':
937 937
                     $val = $this->convertToRadius($val);
938
-                    if (count($val)<1 || count($val)>2) {
938
+                    if (count($val) < 1 || count($val) > 2) {
939 939
                         break;
940 940
                     }
941 941
                     $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 
944 944
                 case 'border-bottom-left-radius':
945 945
                     $val = $this->convertToRadius($val);
946
-                    if (count($val)<1 || count($val)>2) {
946
+                    if (count($val) < 1 || count($val) > 2) {
947 947
                         break;
948 948
                     }
949 949
                     $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -987,21 +987,21 @@  discard block
 block discarded – undo
987 987
                     break;
988 988
 
989 989
                 case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
990
+                    if ($val == 'absolute')       $this->value['position'] = 'absolute';
991
+                    else if ($val == 'relative')  $this->value['position'] = 'relative';
992 992
                     else                        $this->value['position'] = null;
993 993
                     break;
994 994
 
995 995
                 case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
996
+                    if ($val == 'left')           $this->value['float'] = 'left';
997
+                    else if ($val == 'right')     $this->value['float'] = 'right';
998 998
                     else                        $this->value['float'] = null;
999 999
                     break;
1000 1000
 
1001 1001
                 case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1002
+                    if ($val == 'inline')         $this->value['display'] = 'inline';
1003
+                    else if ($val == 'block')     $this->value['display'] = 'block';
1004
+                    else if ($val == 'none')      $this->value['display'] = 'none';
1005 1005
                     else                        $this->value['display'] = null;
1006 1006
                     break;
1007 1007
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                 case 'list-style':
1016 1016
                 case 'list-style-type':
1017 1017
                 case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1018
+                    if ($nom == 'list-style') $nom = 'list-style-type';
1019 1019
                     $this->value[$nom] = $val;
1020 1020
                     break;
1021 1021
 
@@ -1027,27 +1027,27 @@  discard block
 block discarded – undo
1027 1027
         $return = true;
1028 1028
 
1029 1029
         // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1030
+        if ($this->value['margin']['t'] === null) $this->value['margin']['t'] = $this->value['font-size'];
1031
+        if ($this->value['margin']['b'] === null) $this->value['margin']['b'] = $this->value['font-size'];
1032 1032
 
1033 1033
         // force the text align to left, if asked by html2pdf
1034 1034
         if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035 1035
 
1036 1036
         // correction on the width (quick box)
1037
-        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1037
+        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position'] != 'absolute') {
1038 1038
             $this->value['width'] = $this->getLastWidth();
1039
-            $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1039
+            $this->value['width'] -= $this->value['margin']['l'] + $this->value['margin']['r'];
1040 1040
         } else {
1041 1041
             if ($correctWidth) {
1042 1042
                 if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
-                    $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
-                    $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1043
+                    $this->value['width'] -= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
+                    $this->value['width'] -= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045 1045
                 }
1046 1046
                 if (in_array($tagName, array('th', 'td'))) {
1047
-                    $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1047
+                    $this->value['width'] -= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048 1048
                     $return = false;
1049 1049
                 }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1050
+                if ($this->value['width'] < 0) $this->value['width'] = 0;
1051 1051
             } else {
1052 1052
                 if ($this->value['width']) {
1053 1053
                     if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
             if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065 1065
         }
1066 1066
 
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1067
+        if ($this->value['top'] != null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
+        if ($this->value['bottom'] != null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
+        if ($this->value['left'] != null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
+        if ($this->value['right'] != null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071 1071
 
1072 1072
         if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073 1073
         if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
     public function getLineHeight()
1085 1085
     {
1086 1086
         $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1087
+        if ($val == 'normal') $val = '108%';
1088 1088
         return $this->convertToMM($val, $this->value['font-size']);
1089 1089
     }
1090 1090
 
@@ -1097,12 +1097,12 @@  discard block
 block discarded – undo
1097 1097
      */
1098 1098
     public function getLastWidth($mode = false)
1099 1099
     {
1100
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1100
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1101 1101
             if ($this->table[$k]['width']) {
1102 1102
                 $w = $this->table[$k]['width'];
1103 1103
                 if ($mode) {
1104
-                    $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
-                    $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1104
+                    $w += $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
+                    $w += $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106 1106
                 }
1107 1107
                 return $w;
1108 1108
             }
@@ -1119,12 +1119,12 @@  discard block
 block discarded – undo
1119 1119
      */
1120 1120
     public function getLastHeight($mode = false)
1121 1121
     {
1122
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1122
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1123 1123
             if ($this->table[$k]['height']) {
1124 1124
                 $h = $this->table[$k]['height'];
1125 1125
                 if ($mode) {
1126
-                    $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
-                    $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1126
+                    $h += $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
+                    $h += $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128 1128
                 }
1129 1129
                 return $h;
1130 1130
             }
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
      */
1141 1141
     public function getFloat()
1142 1142
     {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1143
+        if ($this->value['float'] == 'left')    return 'left';
1144
+        if ($this->value['float'] == 'right')   return 'right';
1145 1145
         return null;
1146 1146
     }
1147 1147
 
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
     public function getLastValue($key)
1156 1156
     {
1157 1157
         $nb = count($this->table);
1158
-        if ($nb>0) {
1159
-            return $this->table[$nb-1][$key];
1158
+        if ($nb > 0) {
1159
+            return $this->table[$nb - 1][$key];
1160 1160
         } else {
1161 1161
             return null;
1162 1162
         }
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
      */
1171 1171
     protected function _getLastAbsoluteX()
1172 1172
     {
1173
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1173
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1174 1174
             if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175 1175
         }
1176 1176
         return $this->_pdf->getlMargin();
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      */
1185 1185
     protected function _getLastAbsoluteY()
1186 1186
     {
1187
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1187
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1188 1188
             if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189 1189
         }
1190 1190
         return $this->_pdf->gettMargin();
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
         // get the list of the selectors of each tags
1208 1208
         $lst = array();
1209 1209
         $lst[] = $this->value['id_lst'];
1210
-        for ($i=count($this->table)-1; $i>=0; $i--) {
1210
+        for ($i = count($this->table) - 1; $i >= 0; $i--) {
1211 1211
             $lst[] = $this->table[$i]['id_lst'];
1212 1212
         }
1213 1213
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
     protected function _getReccursiveStyle($key, $lst, $next = null)
1241 1241
     {
1242 1242
         // if next step
1243
-        if ($next!==null) {
1243
+        if ($next !== null) {
1244 1244
             // we remove this step
1245 1245
             if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246 1246
             array_shift($lst);
@@ -1254,18 +1254,18 @@  discard block
 block discarded – undo
1254 1254
         // for each selector of the current step
1255 1255
         foreach ($lst[0] as $name) {
1256 1256
             // if selector = key => ok
1257
-            if ($key==$name) {
1257
+            if ($key == $name) {
1258 1258
                 return true;
1259 1259
             }
1260 1260
 
1261 1261
             // if the end of the key = the selector and the next step is ok => ok
1262
-            if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1262
+            if (substr($key, -strlen(' ' . $name)) == ' ' . $name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263 1263
                 return true;
1264 1264
             }
1265 1265
         }
1266 1266
 
1267 1267
         // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
-        if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1268
+        if ($next !== null && $this->_getReccursiveStyle($key, $lst, '')) {
1269 1269
             return true;
1270 1270
         }
1271 1271
 
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
         foreach ($css as $value) {
1305 1305
 
1306 1306
             // if no border => return none
1307
-            if ($value=='none' || $value=='hidden') {
1307
+            if ($value == 'none' || $value == 'hidden') {
1308 1308
                 return $none;
1309 1309
             }
1310 1310
 
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
             $tmp = $this->convertToMM($value);
1313 1313
 
1314 1314
             // if the convert is ok => it is a width
1315
-            if ($tmp!==null) {
1315
+            if ($tmp !== null) {
1316 1316
                 $width = $tmp;
1317 1317
             // else, it could be the type
1318 1318
             } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
@@ -1340,16 +1340,16 @@  discard block
 block discarded – undo
1340 1340
     protected function _duplicateBorder(&$val)
1341 1341
     {
1342 1342
         // 1 value => L => RTB
1343
-        if (count($val)==1) {
1343
+        if (count($val) == 1) {
1344 1344
             $val[1] = $val[0];
1345 1345
             $val[2] = $val[0];
1346 1346
             $val[3] = $val[0];
1347 1347
         // 2 values => L => R & T => B
1348
-        } else if (count($val)==2) {
1348
+        } else if (count($val) == 2) {
1349 1349
             $val[2] = $val[0];
1350 1350
             $val[3] = $val[1];
1351 1351
         // 3 values => T => B
1352
-        } else if (count($val)==3) {
1352
+        } else if (count($val) == 3) {
1353 1353
             $val[3] = $val[1];
1354 1354
         }
1355 1355
     }
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
             if ($ok) {
1394 1394
                 $value['color'] = $color;
1395 1395
             // else if transparent => no coloàr
1396
-            } else if ($val=='transparent') {
1396
+            } else if ($val == 'transparent') {
1397 1397
                 $value['color'] = null;
1398 1398
             // else
1399 1399
             } else {
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                     $value['repeat'] = $repeat;
1406 1406
                 // else => it could only be a position
1407 1407
                 } else {
1408
-                    $pos.= ($pos ? ' ' : '').$val;
1408
+                    $pos .= ($pos ? ' ' : '') . $val;
1409 1409
                 }
1410 1410
             }
1411 1411
         }
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
     public function convertBackgroundColor($css)
1429 1429
     {
1430 1430
         $res = null;
1431
-        if ($css=='transparent') return null;
1431
+        if ($css == 'transparent') return null;
1432 1432
         else                     return $this->convertToColor($css, $res);
1433 1433
     }
1434 1434
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
     public function convertBackgroundImage($css)
1443 1443
     {
1444
-        if ($css=='none')
1444
+        if ($css == 'none')
1445 1445
             return null;
1446 1446
         else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447 1447
             return $match[1];
@@ -1466,11 +1466,11 @@  discard block
 block discarded – undo
1466 1466
         $css = explode(' ', $css);
1467 1467
 
1468 1468
         // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
-        if (count($css)<2) {
1469
+        if (count($css) < 2) {
1470 1470
             if (!$css[0]) return null;
1471 1471
             $css[1] = 'center';
1472 1472
         }
1473
-        if (count($css)>2) return null;
1473
+        if (count($css) > 2) return null;
1474 1474
 
1475 1475
         // prepare the values
1476 1476
         $x = 0;
@@ -1478,21 +1478,21 @@  discard block
 block discarded – undo
1478 1478
         $res = true;
1479 1479
 
1480 1480
         // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1481
+        if ($css[0] == 'left')        $x = '0%';
1482
+        else if ($css[0] == 'center') $x = '50%';
1483
+        else if ($css[0] == 'right')  $x = '100%';
1484
+        else if ($css[0] == 'top')    $y = '0%';
1485
+        else if ($css[0] == 'bottom') $y = '100%';
1486 1486
         else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487 1487
         else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488 1488
         else $res = false;
1489 1489
 
1490 1490
         // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1491
+        if ($css[1] == 'left')        $x = '0%';
1492
+        else if ($css[1] == 'right')  $x = '100%';
1493
+        else if ($css[1] == 'top')    $y = '0%';
1494
+        else if ($css[1] == 'center') $y = '50%';
1495
+        else if ($css[1] == 'bottom') $y = '100%';
1496 1496
         else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497 1497
         else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498 1498
         else $res = false;
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
      */
1511 1511
     public function convertBackgroundRepeat($css)
1512 1512
     {
1513
-        switch($css)
1513
+        switch ($css)
1514 1514
         {
1515 1515
             case 'repeat':
1516 1516
                 return array(true, true);
@@ -1532,15 +1532,15 @@  discard block
 block discarded – undo
1532 1532
      * @param  float  $old parent distance
1533 1533
      * @return float  $value
1534 1534
      */
1535
-    public function convertToMM($css, $old=0.)
1535
+    public function convertToMM($css, $old = 0.)
1536 1536
     {
1537 1537
         $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1538
+        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css .= 'px';
1539
+        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4 / 96. * str_replace('px', '', $css);
1540
+        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4 / 72. * str_replace('pt', '', $css);
1541 1541
         else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1542
+        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1. * str_replace('mm', '', $css);
1543
+        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1. * $old * str_replace('%', '', $css) / 100.;
1544 1544
         else                                              $css = null;
1545 1545
 
1546 1546
         return $css;
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
             $v = trim($v);
1563 1563
             if ($v) {
1564 1564
                 $v = $this->convertToMM($v, 0);
1565
-                if ($v!==null) {
1565
+                if ($v !== null) {
1566 1566
                     $css[$k] = $v;
1567 1567
                 } else {
1568 1568
                     unset($css[$k]);
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
         $res = true;
1591 1591
 
1592 1592
         // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1593
+        if (strtolower($css) == 'transparent') return array(null, null, null);
1594 1594
 
1595 1595
         // HTML color
1596 1596
         if (isset($this->_htmlColor[strtolower($css)])) {
@@ -1611,9 +1611,9 @@  discard block
 block discarded – undo
1611 1611
 
1612 1612
         // like #FFF
1613 1613
         if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
-            $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
-            $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
-            $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1614
+            $r = floatVal(hexdec(substr($css, 1, 1) . substr($css, 1, 1)));
1615
+            $v = floatVal(hexdec(substr($css, 2, 1) . substr($css, 2, 1)));
1616
+            $b = floatVal(hexdec(substr($css, 3, 1) . substr($css, 3, 1)));
1617 1617
             return array($r, $v, $b);
1618 1618
         }
1619 1619
 
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
             $r = $this->_convertSubColor($match[1]);
1623 1623
             $v = $this->_convertSubColor($match[2]);
1624 1624
             $b = $this->_convertSubColor($match[3]);
1625
-            return array($r*255., $v*255., $b*255.);
1625
+            return array($r * 255., $v * 255., $b * 255.);
1626 1626
         }
1627 1627
 
1628 1628
         // like cmyk(100, 100, 100, 100)
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
             $m = $this->_convertSubColor($match[2]);
1632 1632
             $y = $this->_convertSubColor($match[3]);
1633 1633
             $k = $this->_convertSubColor($match[4]);
1634
-            return array($c*100., $m*100., $y*100., $k*100.);
1634
+            return array($c * 100., $m * 100., $y * 100., $k * 100.);
1635 1635
         }
1636 1636
 
1637 1637
         $res = false;
@@ -1647,11 +1647,11 @@  discard block
 block discarded – undo
1647 1647
      */
1648 1648
     protected function _convertSubColor($c)
1649 1649
     {
1650
-        if (substr($c, -1)=='%') {
1651
-            $c = floatVal(substr($c, 0, -1))/100.;
1650
+        if (substr($c, -1) == '%') {
1651
+            $c = floatVal(substr($c, 0, -1)) / 100.;
1652 1652
         } else {
1653 1653
             $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1654
+            if ($c > 1) $c = $c / 255.;
1655 1655
         }
1656 1656
 
1657 1657
         return $c;
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
         preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676 1676
 
1677 1677
         // for each CSS code
1678
-        for ($k=0; $k<count($match[0]); $k++) {
1678
+        for ($k = 0; $k < count($match[0]); $k++) {
1679 1679
 
1680 1680
             // selectors
1681 1681
             $names = strtolower(trim($match[1][$k]));
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
             $css = array();
1691 1691
             foreach ($styles as $style) {
1692 1692
                 $tmp = explode(':', $style);
1693
-                if (count($tmp)>1) {
1693
+                if (count($tmp) > 1) {
1694 1694
                     $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695 1695
                     $css[trim(strtolower($cod))] = trim($tmp);
1696 1696
                 }
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
                 $name = trim($name);
1706 1706
 
1707 1707
                 // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1708
+                if (strpos($name, ':') !== false) continue;
1709 1709
 
1710 1710
                 // save the value
1711 1711
                 if (!isset($this->css[$name]))
@@ -1742,27 +1742,27 @@  discard block
 block discarded – undo
1742 1742
 
1743 1743
             // read the attributes name=value
1744 1744
             $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
-            preg_match_all('/'.$prop.'/is', $code, $match);
1746
-            for ($k=0; $k<count($match[0]); $k++) {
1745
+            preg_match_all('/' . $prop . '/is', $code, $match);
1746
+            for ($k = 0; $k < count($match[0]); $k++) {
1747 1747
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748 1748
             }
1749 1749
 
1750 1750
             // read the attributes name="value"
1751 1751
             $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
-            preg_match_all('/'.$prop.'/is', $code, $match);
1753
-            for ($k=0; $k<count($match[0]); $k++) {
1752
+            preg_match_all('/' . $prop . '/is', $code, $match);
1753
+            for ($k = 0; $k < count($match[0]); $k++) {
1754 1754
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755 1755
             }
1756 1756
 
1757 1757
             // read the attributes name='value'
1758 1758
             $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
-            preg_match_all('/'.$prop.'/is', $code, $match);
1760
-            for ($k=0; $k<count($match[0]); $k++) {
1759
+            preg_match_all('/' . $prop . '/is', $code, $match);
1760
+            for ($k = 0; $k < count($match[0]); $k++) {
1761 1761
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762 1762
             }
1763 1763
 
1764 1764
             // if type text/css => we keep it
1765
-            if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1765
+            if (isset($tmp['type']) && strtolower($tmp['type']) == 'text/css' && isset($tmp['href'])) {
1766 1766
 
1767 1767
                 // get the href
1768 1768
                 $url = $tmp['href'];
@@ -1771,26 +1771,26 @@  discard block
 block discarded – undo
1771 1771
                 $content = @file_get_contents($url);
1772 1772
 
1773 1773
                 // if "http://" in the url
1774
-                if (strpos($url, 'http://')!==false) {
1774
+                if (strpos($url, 'http://') !== false) {
1775 1775
 
1776 1776
                     // get the domain "http://xxx/"
1777 1777
                     $url = str_replace('http://', '', $url);
1778 1778
                     $url = explode('/', $url);
1779
-                    $urlMain = 'http://'.$url[0].'/';
1779
+                    $urlMain = 'http://' . $url[0] . '/';
1780 1780
 
1781 1781
                     // get the absolute url of the path
1782
-                    $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1782
+                    $urlSelf = $url; unset($urlSelf[count($urlSelf) - 1]); $urlSelf = 'http://' . implode('/', $urlSelf) . '/';
1783 1783
 
1784 1784
                     // adapt the url in the css content
1785
-                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
-                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1785
+                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url(' . $urlSelf . '$1)', $content);
1786
+                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url(' . $urlMain . '$1)', $content);
1787 1787
                 } else {
1788 1788
 // @TODO correction on url in absolute on a local css content
1789 1789
                     // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790 1790
                 }
1791 1791
 
1792 1792
                 // add to the CSS content
1793
-                $style.= $content."\n";
1793
+                $style .= $content . "\n";
1794 1794
             }
1795 1795
         }
1796 1796
 
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
             // add to the CSS content
1804 1804
             $code = str_replace('<!--', '', $code);
1805 1805
             $code = str_replace('-->', '', $code);
1806
-            $style.= $code."\n";
1806
+            $style .= $code . "\n";
1807 1807
         }
1808 1808
 
1809 1809
         //analyse the css content
Please login to merge, or discard this patch.
Braces   +392 added lines, -156 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - parsingCss class
4 6
  *
@@ -82,7 +84,9 @@  discard block
 block discarded – undo
82 84
     {
83 85
         $old = $this->_defaultFont;
84 86
         $this->_defaultFont = $default;
85
-        if ($default) $this->value['font-family'] = $default;
87
+        if ($default) {
88
+        	$this->value['font-family'] = $default;
89
+        }
86 90
         return $old;
87 91
     }
88 92
 
@@ -179,7 +183,9 @@  discard block
 block discarded – undo
179 183
 
180 184
         // prepare the Collapse attribute
181 185
         $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
-        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
186
+        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) {
187
+        	$collapse = false;
188
+        }
183 189
 
184 190
         // set the global css values
185 191
         $this->value['position']   = null;
@@ -315,20 +321,23 @@  discard block
 block discarded – undo
315 321
         $style = $b.$i;
316 322
 
317 323
         if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
324
+            if($family=='arial') {
325
+                            $family='helvetica';
326
+            } elseif($family=='symbol' || $family=='zapfdingbats') {
327
+                            $style='';
328
+            }
322 329
 
323 330
             $fontkey = $family.$style;
324
-            if (!$this->_pdf->isLoadedFont($fontkey))
325
-                $family = $this->_defaultFont;
331
+            if (!$this->_pdf->isLoadedFont($fontkey)) {
332
+                            $family = $this->_defaultFont;
333
+            }
326 334
         }
327 335
 
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
336
+        if($family=='arial') {
337
+                    $family='helvetica';
338
+        } elseif($family=='symbol' || $family=='zapfdingbats') {
339
+                    $style='';
340
+        }
332 341
 
333 342
         // complete style
334 343
         $style.= $u.$d.$o;
@@ -340,10 +349,11 @@  discard block
 block discarded – undo
340 349
         // apply the font
341 350
         $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342 351
         $this->_pdf->setTextColorArray($this->value['color']);
343
-        if ($this->value['background']['color'])
344
-            $this->_pdf->setFillColorArray($this->value['background']['color']);
345
-        else
346
-            $this->_pdf->setFillColor(255);
352
+        if ($this->value['background']['color']) {
353
+                    $this->_pdf->setFillColorArray($this->value['background']['color']);
354
+        } else {
355
+                    $this->_pdf->setFillColor(255);
356
+        }
347 357
     }
348 358
 
349 359
      /**
@@ -375,7 +385,9 @@  discard block
 block discarded – undo
375 385
      */
376 386
     public function restorePosition()
377 387
     {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
388
+        if ($this->value['y']==$this->_pdf->getY()) {
389
+        	$this->_pdf->setY($this->value['yc'], false);
390
+        }
379 391
     }
380 392
 
381 393
      /**
@@ -396,18 +408,26 @@  discard block
 block discarded – undo
396 408
         if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397 409
             if ($this->value['right']!==null) {
398 410
                 $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
411
+                if ($this->value['margin']['r']) {
412
+                	$x-= $this->value['margin']['r'];
413
+                }
400 414
             } else {
401 415
                 $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
416
+                if ($this->value['margin']['l']) {
417
+                	$x+= $this->value['margin']['l'];
418
+                }
403 419
             }
404 420
 
405 421
             if ($this->value['bottom']!==null) {
406 422
                 $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
423
+                if ($this->value['margin']['b']) {
424
+                	$y-= $this->value['margin']['b'];
425
+                }
408 426
             } else {
409 427
                 $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
428
+                if ($this->value['margin']['t']) {
429
+                	$y+= $this->value['margin']['t'];
430
+                }
411 431
             }
412 432
 
413 433
             if ($this->value['position']=='relative') {
@@ -420,8 +440,12 @@  discard block
 block discarded – undo
420 440
         } else {
421 441
             $this->value['x'] = $currentX;
422 442
             $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
443
+            if ($this->value['margin']['l']) {
444
+            	$this->value['x']+= $this->value['margin']['l'];
445
+            }
446
+            if ($this->value['margin']['t']) {
447
+            	$this->value['y']+= $this->value['margin']['t'];
448
+            }
425 449
         }
426 450
 
427 451
         // save the new position
@@ -478,8 +502,12 @@  discard block
 block discarded – undo
478 502
     {
479 503
         // prepare
480 504
         $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
-        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
505
+        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id) {
506
+        	$id   = null;
507
+        }
508
+        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) {
509
+        	$name = null;
510
+        }
483 511
 
484 512
         // read the class attribute
485 513
         $class = array();
@@ -487,7 +515,9 @@  discard block
 block discarded – undo
487 515
         $tmp = explode(' ', $tmp);
488 516
         foreach ($tmp as $k => $v) {
489 517
             $v = trim($v);
490
-            if ($v) $class[] = $v;
518
+            if ($v) {
519
+            	$class[] = $v;
520
+            }
491 521
         }
492 522
 
493 523
         // identify the tag, and the direct styles
@@ -526,10 +556,18 @@  discard block
 block discarded – undo
526 556
         // adding the style from the tag
527 557
         $styles = array_merge($styles, $param['style']);
528 558
 
529
-        if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
-        if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
-        if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
559
+        if (isset($styles['stroke'])) {
560
+        	$this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
561
+        }
562
+        if (isset($styles['stroke-width'])) {
563
+        	$this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
564
+        }
565
+        if (isset($styles['fill'])) {
566
+        	$this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
567
+        }
568
+        if (isset($styles['fill-opacity'])) {
569
+        	$this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
570
+        }
533 571
 
534 572
         return $this->value['svg'];
535 573
     }
@@ -546,8 +584,12 @@  discard block
 block discarded – undo
546 584
     {
547 585
         // prepare the informations
548 586
         $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
587
+        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id) {
588
+        	$id   = null;
589
+        }
590
+        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) {
591
+        	$name = null;
592
+        }
551 593
 
552 594
         // get the class names to use
553 595
         $class = array();
@@ -555,7 +597,9 @@  discard block
 block discarded – undo
555 597
         $tmp = explode(' ', $tmp);
556 598
         foreach ($tmp as $k => $v) {
557 599
             $v = trim($v);
558
-            if ($v) $class[] = $v;
600
+            if ($v) {
601
+            	$class[] = $v;
602
+            }
559 603
         }
560 604
 
561 605
         // prepare the values, and the list of css tags to identify
@@ -584,7 +628,9 @@  discard block
 block discarded – undo
584 628
 
585 629
         // merge with the css styles from tag
586 630
         $styles = array_merge($styles, $param['style']);
587
-        if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
631
+        if (isset($param['allwidth']) && !isset($styles['width'])) {
632
+        	$styles['width'] = '100%';
633
+        }
588 634
 
589 635
         // reset some styles, depending on the tag name
590 636
         $this->resetStyle($tagName);
@@ -593,8 +639,9 @@  discard block
 block discarded – undo
593 639
         if ($legacy) {
594 640
             foreach ($legacy as $legacyName => $legacyValue) {
595 641
                 if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
597
-                        $this->value[$legacyName][$legacy2Name] = $legacy2Value;
642
+                    foreach($legacyValue as $legacy2Name => $legacy2Value) {
643
+                                            $this->value[$legacyName][$legacy2Name] = $legacy2Value;
644
+                    }
598 645
                 } else {
599 646
                     $this->value[$legacyName] = $legacyValue;
600 647
                 }
@@ -612,7 +659,9 @@  discard block
 block discarded – undo
612 659
                 case 'font-family':
613 660
                     $val = explode(',', $val);
614 661
                     $val = trim($val[0]);
615
-                    if ($val) $this->value['font-family'] = $val;
662
+                    if ($val) {
663
+                    	$this->value['font-family'] = $val;
664
+                    }
616 665
                     break;
617 666
 
618 667
                 case 'font-weight':
@@ -635,13 +684,17 @@  discard block
 block discarded – undo
635 684
                     break;
636 685
 
637 686
                 case 'text-transform':
638
-                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
687
+                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) {
688
+                    	$val = 'none';
689
+                    }
639 690
                     $this->value['text-transform']  = $val;
640 691
                     break;
641 692
 
642 693
                 case 'font-size':
643 694
                     $val = $this->convertToMM($val, $this->value['font-size']);
644
-                    if ($val) $this->value['font-size'] = $val;
695
+                    if ($val) {
696
+                    	$this->value['font-size'] = $val;
697
+                    }
645 698
                     break;
646 699
 
647 700
                 case 'color':
@@ -657,7 +710,9 @@  discard block
 block discarded – undo
657 710
 
658 711
                 case 'text-align':
659 712
                     $val = strtolower($val);
660
-                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
713
+                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) {
714
+                    	$val = 'left';
715
+                    }
661 716
                     $this->value['text-align'] = $val;
662 717
                     break;
663 718
 
@@ -667,7 +722,9 @@  discard block
 block discarded – undo
667 722
 
668 723
                 case 'width':
669 724
                     $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
725
+                    if ($this->value['width'] && substr($val, -1)=='%') {
726
+                    	$correctWidth=true;
727
+                    }
671 728
                     $noWidth = false;
672 729
                     break;
673 730
 
@@ -676,18 +733,26 @@  discard block
 block discarded – undo
676 733
                     break;
677 734
 
678 735
                 case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
736
+                    if (preg_match('/^[0-9\.]+$/isU', $val)) {
737
+                    	$val = floor($val*100).'%';
738
+                    }
680 739
                     $this->value['line-height'] = $val;
681 740
                     break;
682 741
 
683 742
                 case 'rotate':
684
-                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
743
+                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) {
744
+                    	$val = null;
745
+                    }
746
+                    if ($val<0) {
747
+                    	$val+= 360;
748
+                    }
686 749
                     $this->value['rotate'] = $val;
687 750
                     break;
688 751
 
689 752
                 case 'overflow':
690
-                    if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
753
+                    if (!in_array($val, array('visible', 'hidden'))) {
754
+                    	$val = 'visible';
755
+                    }
691 756
                     $this->value['overflow'] = $val;
692 757
                     break;
693 758
 
@@ -779,10 +844,18 @@  discard block
 block discarded – undo
779 844
                         }
780 845
                     }
781 846
                     $this->_duplicateBorder($val);
782
-                    if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
-                    if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
-                    if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
-                    if ($val[3]) $this->value['border']['l']['type'] = $val[3];
847
+                    if ($val[0]) {
848
+                    	$this->value['border']['t']['type'] = $val[0];
849
+                    }
850
+                    if ($val[1]) {
851
+                    	$this->value['border']['r']['type'] = $val[1];
852
+                    }
853
+                    if ($val[2]) {
854
+                    	$this->value['border']['b']['type'] = $val[2];
855
+                    }
856
+                    if ($val[3]) {
857
+                    	$this->value['border']['l']['type'] = $val[3];
858
+                    }
786 859
                     break;
787 860
 
788 861
                 case 'border-top-style':
@@ -804,8 +877,9 @@  discard block
 block discarded – undo
804 877
                     break;
805 878
 
806 879
                 case 'border-left-style':
807
-                    if (in_array($val, array('solid', 'dotted', 'dashed')))
808
-                        $this->value['border']['l']['type'] = $val;
880
+                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
881
+                                            $this->value['border']['l']['type'] = $val;
882
+                    }
809 883
                     break;
810 884
 
811 885
                 case 'border-color':
@@ -819,35 +893,51 @@  discard block
 block discarded – undo
819 893
                             }
820 894
                     }
821 895
                     $this->_duplicateBorder($val);
822
-                    if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
-                    if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
-                    if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
-                    if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
896
+                    if (is_array($val[0])) {
897
+                    	$this->value['border']['t']['color'] = $val[0];
898
+                    }
899
+                    if (is_array($val[1])) {
900
+                    	$this->value['border']['r']['color'] = $val[1];
901
+                    }
902
+                    if (is_array($val[2])) {
903
+                    	$this->value['border']['b']['color'] = $val[2];
904
+                    }
905
+                    if (is_array($val[3])) {
906
+                    	$this->value['border']['l']['color'] = $val[3];
907
+                    }
826 908
 
827 909
                     break;
828 910
 
829 911
                 case 'border-top-color':
830 912
                     $res = false;
831 913
                     $val = $this->convertToColor($val, $res);
832
-                    if ($res) $this->value['border']['t']['color'] = $val;
914
+                    if ($res) {
915
+                    	$this->value['border']['t']['color'] = $val;
916
+                    }
833 917
                     break;
834 918
 
835 919
                 case 'border-right-color':
836 920
                     $res = false;
837 921
                     $val = $this->convertToColor($val, $res);
838
-                    if ($res) $this->value['border']['r']['color'] = $val;
922
+                    if ($res) {
923
+                    	$this->value['border']['r']['color'] = $val;
924
+                    }
839 925
                     break;
840 926
 
841 927
                 case 'border-bottom-color':
842 928
                     $res = false;
843 929
                     $val = $this->convertToColor($val, $res);
844
-                    if ($res) $this->value['border']['b']['color'] = $val;
930
+                    if ($res) {
931
+                    	$this->value['border']['b']['color'] = $val;
932
+                    }
845 933
                     break;
846 934
 
847 935
                 case 'border-left-color':
848 936
                     $res = false;
849 937
                     $val = $this->convertToColor($val, $res);
850
-                    if ($res) $this->value['border']['l']['color'] = $val;
938
+                    if ($res) {
939
+                    	$this->value['border']['l']['color'] = $val;
940
+                    }
851 941
                     break;
852 942
 
853 943
                 case 'border-width':
@@ -856,34 +946,52 @@  discard block
 block discarded – undo
856 946
                             $val[$valK] = $this->convertToMM($valV, 0);
857 947
                     }
858 948
                     $this->_duplicateBorder($val);
859
-                    if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
-                    if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
-                    if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
-                    if ($val[3]) $this->value['border']['l']['width'] = $val[3];
949
+                    if ($val[0]) {
950
+                    	$this->value['border']['t']['width'] = $val[0];
951
+                    }
952
+                    if ($val[1]) {
953
+                    	$this->value['border']['r']['width'] = $val[1];
954
+                    }
955
+                    if ($val[2]) {
956
+                    	$this->value['border']['b']['width'] = $val[2];
957
+                    }
958
+                    if ($val[3]) {
959
+                    	$this->value['border']['l']['width'] = $val[3];
960
+                    }
863 961
                     break;
864 962
 
865 963
                 case 'border-top-width':
866 964
                     $val = $this->convertToMM($val, 0);
867
-                    if ($val) $this->value['border']['t']['width'] = $val;
965
+                    if ($val) {
966
+                    	$this->value['border']['t']['width'] = $val;
967
+                    }
868 968
                     break;
869 969
 
870 970
                 case 'border-right-width':
871 971
                     $val = $this->convertToMM($val, 0);
872
-                    if ($val) $this->value['border']['r']['width'] = $val;
972
+                    if ($val) {
973
+                    	$this->value['border']['r']['width'] = $val;
974
+                    }
873 975
                     break;
874 976
 
875 977
                 case 'border-bottom-width':
876 978
                     $val = $this->convertToMM($val, 0);
877
-                    if ($val) $this->value['border']['b']['width'] = $val;
979
+                    if ($val) {
980
+                    	$this->value['border']['b']['width'] = $val;
981
+                    }
878 982
                     break;
879 983
 
880 984
                 case 'border-left-width':
881 985
                     $val = $this->convertToMM($val, 0);
882
-                    if ($val) $this->value['border']['l']['width'] = $val;
986
+                    if ($val) {
987
+                    	$this->value['border']['l']['width'] = $val;
988
+                    }
883 989
                     break;
884 990
 
885 991
                 case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
992
+                    if ($tagName=='table') {
993
+                    	$this->value['border']['collapse'] = ($val=='collapse');
994
+                    }
887 995
                     break;
888 996
 
889 997
                 case 'border-radius':
@@ -895,17 +1003,29 @@  discard block
 block discarded – undo
895 1003
                     if (count($valH)<1 || count($valH)>4) {
896 1004
                         break;
897 1005
                     }
898
-                    if (!isset($valH[1])) $valH[1] = $valH[0];
899
-                    if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
-                    if (!isset($valH[3])) $valH[3] = $valH[1];
1006
+                    if (!isset($valH[1])) {
1007
+                    	$valH[1] = $valH[0];
1008
+                    }
1009
+                    if (!isset($valH[2])) {
1010
+                    	$valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
1011
+                    }
1012
+                    if (!isset($valH[3])) {
1013
+                    	$valH[3] = $valH[1];
1014
+                    }
901 1015
                     if (isset($val[1])) {
902 1016
                         $valV = $this->convertToRadius(trim($val[1]));
903 1017
                         if (count($valV)<1 || count($valV)>4) {
904 1018
                             break;
905 1019
                         }
906
-                        if (!isset($valV[1])) $valV[1] = $valV[0];
907
-                        if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
-                        if (!isset($valV[3])) $valV[3] = $valV[1];
1020
+                        if (!isset($valV[1])) {
1021
+                        	$valV[1] = $valV[0];
1022
+                        }
1023
+                        if (!isset($valV[2])) {
1024
+                        	$valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
1025
+                        }
1026
+                        if (!isset($valV[3])) {
1027
+                        	$valV[3] = $valV[1];
1028
+                        }
909 1029
                     } else {
910 1030
                         $valV = $valH;
911 1031
                     }
@@ -987,22 +1107,35 @@  discard block
 block discarded – undo
987 1107
                     break;
988 1108
 
989 1109
                 case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
992
-                    else                        $this->value['position'] = null;
1110
+                    if ($val=='absolute') {
1111
+                    	$this->value['position'] = 'absolute';
1112
+                    } else if ($val=='relative') {
1113
+                    	$this->value['position'] = 'relative';
1114
+                    } else {
1115
+                    	$this->value['position'] = null;
1116
+                    }
993 1117
                     break;
994 1118
 
995 1119
                 case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
998
-                    else                        $this->value['float'] = null;
1120
+                    if ($val=='left') {
1121
+                    	$this->value['float'] = 'left';
1122
+                    } else if ($val=='right') {
1123
+                    	$this->value['float'] = 'right';
1124
+                    } else {
1125
+                    	$this->value['float'] = null;
1126
+                    }
999 1127
                     break;
1000 1128
 
1001 1129
                 case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1005
-                    else                        $this->value['display'] = null;
1130
+                    if ($val=='inline') {
1131
+                    	$this->value['display'] = 'inline';
1132
+                    } else if ($val=='block') {
1133
+                    	$this->value['display'] = 'block';
1134
+                    } else if ($val=='none') {
1135
+                    	$this->value['display'] = 'none';
1136
+                    } else {
1137
+                    	$this->value['display'] = null;
1138
+                    }
1006 1139
                     break;
1007 1140
 
1008 1141
                 case 'top':
@@ -1015,7 +1148,9 @@  discard block
 block discarded – undo
1015 1148
                 case 'list-style':
1016 1149
                 case 'list-style-type':
1017 1150
                 case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1151
+                    if ($nom=='list-style') {
1152
+                    	$nom = 'list-style-type';
1153
+                    }
1019 1154
                     $this->value[$nom] = $val;
1020 1155
                     break;
1021 1156
 
@@ -1027,11 +1162,17 @@  discard block
 block discarded – undo
1027 1162
         $return = true;
1028 1163
 
1029 1164
         // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1165
+        if ($this->value['margin']['t']===null) {
1166
+        	$this->value['margin']['t'] = $this->value['font-size'];
1167
+        }
1168
+        if ($this->value['margin']['b']===null) {
1169
+        	$this->value['margin']['b'] = $this->value['font-size'];
1170
+        }
1032 1171
 
1033 1172
         // force the text align to left, if asked by html2pdf
1034
-        if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1173
+        if ($this->_onlyLeft) {
1174
+        	$this->value['text-align'] = 'left';
1175
+        }
1035 1176
 
1036 1177
         // correction on the width (quick box)
1037 1178
         if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
@@ -1047,30 +1188,60 @@  discard block
 block discarded – undo
1047 1188
                     $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048 1189
                     $return = false;
1049 1190
                 }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1191
+                if ($this->value['width']<0) {
1192
+                	$this->value['width']=0;
1193
+                }
1051 1194
             } else {
1052 1195
                 if ($this->value['width']) {
1053
-                    if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
-                    if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
-                    if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
-                    if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1196
+                    if ($this->value['border']['l']['width']) {
1197
+                    	$this->value['width'] += $this->value['border']['l']['width'];
1198
+                    }
1199
+                    if ($this->value['border']['r']['width']) {
1200
+                    	$this->value['width'] += $this->value['border']['r']['width'];
1201
+                    }
1202
+                    if ($this->value['padding']['l']) {
1203
+                    	$this->value['width'] += $this->value['padding']['l'];
1204
+                    }
1205
+                    if ($this->value['padding']['r']) {
1206
+                    	$this->value['width'] += $this->value['padding']['r'];
1207
+                    }
1057 1208
                 }
1058 1209
             }
1059 1210
         }
1060 1211
         if ($this->value['height']) {
1061
-            if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
-            if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
-            if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
-            if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1212
+            if ($this->value['border']['b']['width']) {
1213
+            	$this->value['height'] += $this->value['border']['b']['width'];
1214
+            }
1215
+            if ($this->value['border']['t']['width']) {
1216
+            	$this->value['height'] += $this->value['border']['t']['width'];
1217
+            }
1218
+            if ($this->value['padding']['b']) {
1219
+            	$this->value['height'] += $this->value['padding']['b'];
1220
+            }
1221
+            if ($this->value['padding']['t']) {
1222
+            	$this->value['height'] += $this->value['padding']['t'];
1223
+            }
1065 1224
         }
1066 1225
 
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1226
+        if ($this->value['top']!=null) {
1227
+        	$this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1228
+        }
1229
+        if ($this->value['bottom']!=null) {
1230
+        	$this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1231
+        }
1232
+        if ($this->value['left']!=null) {
1233
+        	$this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1234
+        }
1235
+        if ($this->value['right']!=null) {
1236
+        	$this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1237
+        }
1071 1238
 
1072
-        if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
-        if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1239
+        if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) {
1240
+        	$this->value['bottom']  = null;
1241
+        }
1242
+        if ($this->value['left'] && $this->value['right'] && $this->value['width']) {
1243
+        	$this->value['right']   = null;
1244
+        }
1074 1245
 
1075 1246
         return $return;
1076 1247
     }
@@ -1084,7 +1255,9 @@  discard block
 block discarded – undo
1084 1255
     public function getLineHeight()
1085 1256
     {
1086 1257
         $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1258
+        if ($val=='normal') {
1259
+        	$val = '108%';
1260
+        }
1088 1261
         return $this->convertToMM($val, $this->value['font-size']);
1089 1262
     }
1090 1263
 
@@ -1140,8 +1313,12 @@  discard block
 block discarded – undo
1140 1313
      */
1141 1314
     public function getFloat()
1142 1315
     {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1316
+        if ($this->value['float']=='left') {
1317
+        	return 'left';
1318
+        }
1319
+        if ($this->value['float']=='right') {
1320
+        	return 'right';
1321
+        }
1145 1322
         return null;
1146 1323
     }
1147 1324
 
@@ -1171,7 +1348,9 @@  discard block
 block discarded – undo
1171 1348
     protected function _getLastAbsoluteX()
1172 1349
     {
1173 1350
         for ($k=count($this->table)-1; $k>=0; $k--) {
1174
-            if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1351
+            if ($this->table[$k]['x'] && $this->table[$k]['position']) {
1352
+            	return $this->table[$k]['x'];
1353
+            }
1175 1354
         }
1176 1355
         return $this->_pdf->getlMargin();
1177 1356
     }
@@ -1185,7 +1364,9 @@  discard block
 block discarded – undo
1185 1364
     protected function _getLastAbsoluteY()
1186 1365
     {
1187 1366
         for ($k=count($this->table)-1; $k>=0; $k--) {
1188
-            if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1367
+            if ($this->table[$k]['y'] && $this->table[$k]['position']) {
1368
+            	return $this->table[$k]['y'];
1369
+            }
1189 1370
         }
1190 1371
         return $this->_pdf->gettMargin();
1191 1372
     }
@@ -1222,7 +1403,9 @@  discard block
 block discarded – undo
1222 1403
         if (count($getit)) {
1223 1404
             // get them, but in the definition order, because of priority
1224 1405
             asort($getit);
1225
-            foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1406
+            foreach ($getit as $key => $val) {
1407
+            	$styles = array_merge($styles, $this->css[$key]);
1408
+            }
1226 1409
         }
1227 1410
 
1228 1411
         return $styles;
@@ -1242,7 +1425,9 @@  discard block
 block discarded – undo
1242 1425
         // if next step
1243 1426
         if ($next!==null) {
1244 1427
             // we remove this step
1245
-            if ($next) $key = trim(substr($key, 0, -strlen($next)));
1428
+            if ($next) {
1429
+            	$key = trim(substr($key, 0, -strlen($next)));
1430
+            }
1246 1431
             array_shift($lst);
1247 1432
 
1248 1433
             // if no more step to identify => return false
@@ -1294,8 +1479,11 @@  discard block
 block discarded – undo
1294 1479
         $css = explode(' ', $css);
1295 1480
         foreach ($css as $k => $v) {
1296 1481
             $v = trim($v);
1297
-            if ($v) $css[$k] = $v;
1298
-            else    unset($css[$k]);
1482
+            if ($v) {
1483
+            	$css[$k] = $v;
1484
+            } else {
1485
+            	unset($css[$k]);
1486
+            }
1299 1487
         }
1300 1488
         $css = array_values($css);
1301 1489
 
@@ -1320,12 +1508,16 @@  discard block
 block discarded – undo
1320 1508
             // else, it could be the color
1321 1509
             } else {
1322 1510
                 $tmp = $this->convertToColor($value, $res);
1323
-                if ($res) $color = $tmp;
1511
+                if ($res) {
1512
+                	$color = $tmp;
1513
+                }
1324 1514
             }
1325 1515
         }
1326 1516
 
1327 1517
         // if no witdh => return none
1328
-        if (!$width) return $none;
1518
+        if (!$width) {
1519
+        	return $none;
1520
+        }
1329 1521
 
1330 1522
         // return the border properties
1331 1523
         return array('type' => $type, 'width' => $width, 'color' => $color);
@@ -1414,7 +1606,9 @@  discard block
 block discarded – undo
1414 1606
         if ($pos) {
1415 1607
             // try to read it
1416 1608
             $pos = $this->convertBackgroundPosition($pos, $ok);
1417
-            if ($ok) $value['position'] = $pos;
1609
+            if ($ok) {
1610
+            	$value['position'] = $pos;
1611
+            }
1418 1612
         }
1419 1613
     }
1420 1614
 
@@ -1428,8 +1622,11 @@  discard block
 block discarded – undo
1428 1622
     public function convertBackgroundColor($css)
1429 1623
     {
1430 1624
         $res = null;
1431
-        if ($css=='transparent') return null;
1432
-        else                     return $this->convertToColor($css, $res);
1625
+        if ($css=='transparent') {
1626
+        	return null;
1627
+        } else {
1628
+        	return $this->convertToColor($css, $res);
1629
+        }
1433 1630
     }
1434 1631
 
1435 1632
     /**
@@ -1441,12 +1638,13 @@  discard block
 block discarded – undo
1441 1638
      */
1442 1639
     public function convertBackgroundImage($css)
1443 1640
     {
1444
-        if ($css=='none')
1445
-            return null;
1446
-        else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
-            return $match[1];
1448
-        else
1449
-            return null;
1641
+        if ($css=='none') {
1642
+                    return null;
1643
+        } else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) {
1644
+                    return $match[1];
1645
+        } else {
1646
+                    return null;
1647
+        }
1450 1648
     }
1451 1649
 
1452 1650
     /**
@@ -1467,10 +1665,14 @@  discard block
 block discarded – undo
1467 1665
 
1468 1666
         // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469 1667
         if (count($css)<2) {
1470
-            if (!$css[0]) return null;
1668
+            if (!$css[0]) {
1669
+            	return null;
1670
+            }
1471 1671
             $css[1] = 'center';
1472 1672
         }
1473
-        if (count($css)>2) return null;
1673
+        if (count($css)>2) {
1674
+        	return null;
1675
+        }
1474 1676
 
1475 1677
         // prepare the values
1476 1678
         $x = 0;
@@ -1478,24 +1680,42 @@  discard block
 block discarded – undo
1478 1680
         $res = true;
1479 1681
 
1480 1682
         // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1486
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
-        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
-        else $res = false;
1683
+        if ($css[0]=='left') {
1684
+        	$x = '0%';
1685
+        } else if ($css[0]=='center') {
1686
+        	$x = '50%';
1687
+        } else if ($css[0]=='right') {
1688
+        	$x = '100%';
1689
+        } else if ($css[0]=='top') {
1690
+        	$y = '0%';
1691
+        } else if ($css[0]=='bottom') {
1692
+        	$y = '100%';
1693
+        } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) {
1694
+        	$x = $css[0];
1695
+        } else if ($this->convertToMM($css[0])) {
1696
+        	$x = $this->convertToMM($css[0]);
1697
+        } else {
1698
+        	$res = false;
1699
+        }
1489 1700
 
1490 1701
         // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1496
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
-        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
-        else $res = false;
1702
+        if ($css[1]=='left') {
1703
+        	$x = '0%';
1704
+        } else if ($css[1]=='right') {
1705
+        	$x = '100%';
1706
+        } else if ($css[1]=='top') {
1707
+        	$y = '0%';
1708
+        } else if ($css[1]=='center') {
1709
+        	$y = '50%';
1710
+        } else if ($css[1]=='bottom') {
1711
+        	$y = '100%';
1712
+        } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) {
1713
+        	$y = $css[1];
1714
+        } else if ($this->convertToMM($css[1])) {
1715
+        	$y = $this->convertToMM($css[1]);
1716
+        } else {
1717
+        	$res = false;
1718
+        }
1499 1719
 
1500 1720
         // return the values
1501 1721
         return array($x, $y);
@@ -1535,13 +1755,22 @@  discard block
 block discarded – undo
1535 1755
     public function convertToMM($css, $old=0.)
1536 1756
     {
1537 1757
         $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
-        else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
-        else                                              $css = null;
1758
+        if (preg_match('/^[0-9\.\-]+$/isU', $css)) {
1759
+        	$css.= 'px';
1760
+        }
1761
+        if (preg_match('/^[0-9\.\-]+px$/isU', $css)) {
1762
+        	$css = 25.4/96. * str_replace('px', '', $css);
1763
+        } else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) {
1764
+        	$css = 25.4/72. * str_replace('pt', '', $css);
1765
+        } else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) {
1766
+        	$css = 25.4 * str_replace('in', '', $css);
1767
+        } else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) {
1768
+        	$css = 1.*str_replace('mm', '', $css);
1769
+        } else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) {
1770
+        	$css = 1.*$old*str_replace('%', '', $css)/100.;
1771
+        } else {
1772
+        	$css = null;
1773
+        }
1545 1774
 
1546 1775
         return $css;
1547 1776
     }
@@ -1590,7 +1819,9 @@  discard block
 block discarded – undo
1590 1819
         $res = true;
1591 1820
 
1592 1821
         // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1822
+        if (strtolower($css)=='transparent') {
1823
+        	return array(null, null, null);
1824
+        }
1594 1825
 
1595 1826
         // HTML color
1596 1827
         if (isset($this->_htmlColor[strtolower($css)])) {
@@ -1651,7 +1882,9 @@  discard block
 block discarded – undo
1651 1882
             $c = floatVal(substr($c, 0, -1))/100.;
1652 1883
         } else {
1653 1884
             $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1885
+            if ($c>1) {
1886
+            	$c = $c/255.;
1887
+            }
1655 1888
         }
1656 1889
 
1657 1890
         return $c;
@@ -1705,13 +1938,16 @@  discard block
 block discarded – undo
1705 1938
                 $name = trim($name);
1706 1939
 
1707 1940
                 // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1941
+                if (strpos($name, ':')!==false) {
1942
+                	continue;
1943
+                }
1709 1944
 
1710 1945
                 // save the value
1711
-                if (!isset($this->css[$name]))
1712
-                    $this->css[$name] = $css;
1713
-                else
1714
-                    $this->css[$name] = array_merge($this->css[$name], $css);
1946
+                if (!isset($this->css[$name])) {
1947
+                                    $this->css[$name] = $css;
1948
+                } else {
1949
+                                    $this->css[$name] = array_merge($this->css[$name], $css);
1950
+                }
1715 1951
 
1716 1952
             }
1717 1953
         }
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/parsingHtml.class.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -38,6 +38,7 @@  discard block
 block discarded – undo
38 38
      * change the encoding
39 39
      *
40 40
      * @param   string encoding
41
+     * @param string $encoding
41 42
      * @access  public
42 43
      */
43 44
     public function setEncoding($encoding)
@@ -439,6 +440,7 @@  discard block
 block discarded – undo
439 440
      * get a full level of HTML, between an opening and closing corresponding
440 441
      *
441 442
      * @param   integer key
443
+     * @param integer $k
442 444
      * @return  array   actions
443 445
      */
444 446
     public function getLevel($k)
Please login to merge, or discard this patch.
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -11,510 +11,510 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingHtml
13 13
 {
14
-    protected    $_html     = '';        // HTML code to parse
15
-    protected    $_num      = 0;         // table number
16
-    protected    $_level    = 0;         // table level
17
-    protected    $_encoding = '';        // encoding
18
-    public       $code      = array();   // parsed HTML codfe
19
-
20
-    const HTML_TAB = '        ';
21
-
22
-    /**
23
-     * main constructor
24
-     *
25
-     * @param   string encoding
26
-     * @access  public
27
-     */
28
-    public function __construct($encoding = 'UTF-8')
29
-    {
30
-        $this->_num   = 0;
31
-        $this->_level = array($this->_num);
32
-        $this->_html  = '';
33
-        $this->code  = array();
34
-        $this->setEncoding($encoding);
35
-    }
36
-
37
-    /**
38
-     * change the encoding
39
-     *
40
-     * @param   string encoding
41
-     * @access  public
42
-     */
43
-    public function setEncoding($encoding)
44
-    {
45
-        $this->_encoding = $encoding;
46
-    }
47
-
48
-    /**
49
-     * Define the HTML code to parse
50
-     *
51
-     * @param   string HTML code
52
-     * @access  public
53
-     */
54
-    public function setHTML($html)
55
-    {
56
-        // remove the HTML in comment
57
-        $html = preg_replace('/<!--(.*)-->/isU', '', $html);
58
-
59
-        // save the HTML code
60
-        $this->_html = $html;
61
-    }
62
-
63
-    /**
64
-     * parse the HTML code
65
-     *
66
-     * @access public
67
-     */
68
-    public function parse()
69
-    {
70
-        $parents = array();
71
-
72
-        // flag : are we in a <pre> Tag ?
73
-        $tagPreIn = false;
74
-
75
-        // action to use for each line of the content of a <pre> Tag
76
-        $tagPreBr = array(
77
-                    'name' => 'br',
78
-                    'close' => false,
79
-                    'param' => array(
80
-                        'style' => array(),
81
-                        'num'    => 0
82
-                    )
83
-                );
84
-
85
-        // tag that can be not closed
86
-        $tagsNotClosed = array(
87
-            'br', 'hr', 'img', 'col',
88
-            'input', 'link', 'option',
89
-            'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline'
90
-        );
91
-
92
-        // search the HTML tags
93
-        $tmp = array();
94
-        $this->_searchCode($tmp);
95
-
96
-        // all the actions to do
97
-        $actions = array();
98
-
99
-        // foreach part of the HTML code
100
-        foreach ($tmp as $part) {
101
-            // if it is a tag code
102
-            if ($part[0]=='code') {
103
-                // analise the HTML code
104
-                $res = $this->_analiseCode($part[1]);
105
-
106
-                // if it is a real HTML tag
107
-                if ($res) {
108
-                    // save the current posistion in the HTML code
109
-                    $res['html_pos'] = $part[2];
110
-
111
-                    // if the tag must be closed
112
-                    if (!in_array($res['name'], $tagsNotClosed)) {
113
-                        // if it is a closure tag
114
-                        if ($res['close']) {
115
-                            // HTML validation
116
-                            if (count($parents)<1)
117
-                                throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
119
-                                throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
-                            else
121
-                                unset($parents[count($parents)-1]);
122
-                        } else {
123
-                            // if it is a autoclosed tag
124
-                            if ($res['autoclose']) {
125
-                                // save the opened tag
126
-                                $actions[] = $res;
127
-
128
-                                // prepare the closed tag
129
-                                $res['params'] = array();
130
-                                $res['close'] = true;
131
-                            }
132
-                            // else :add a child for validation
133
-                            else
134
-                                $parents[count($parents)] = $res['name'];
135
-                        }
136
-
137
-                        // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
-                        if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
139
-                            $tagPreIn = !$res['close'];
140
-                        }
141
-                    }
142
-
143
-                    // save the actions to convert
144
-                    $actions[] = $res;
145
-                } else { // else (it is not a real HTML tag => we transform it in Texte
146
-                    $part[0]='txt';
147
-                }
148
-            }
149
-            // if it is text
150
-            if ($part[0]=='txt') {
151
-                // if we are not in a <pre> tag
152
-                if (!$tagPreIn) {
153
-                    // save the action
154
-                    $actions[] = array(
155
-                        'name'    => 'write',
156
-                        'close'    => false,
157
-                        'param' => array('txt' => $this->_prepareTxt($part[1])),
158
-                    );
159
-                } else { // else (if we are in a <pre> tag)
160
-                    // prepare the text
161
-                    $part[1] = str_replace("\r", '', $part[1]);
162
-                    $part[1] = explode("\n", $part[1]);
163
-
164
-                    // foreach line of the text
165
-                    foreach ($part[1] as $k => $txt) {
166
-                        // transform the line
167
-                        $txt = str_replace("\t", self::HTML_TAB, $txt);
168
-                        $txt = str_replace(' ', '&nbsp;', $txt);
169
-
170
-                        // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
172
-
173
-                        // save the action
174
-                        $actions[] = array(
175
-                            'name'    => 'write',
176
-                            'close'    => false,
177
-                            'param' => array('txt' => $this->_prepareTxt($txt, false)),
178
-                        );
179
-                    }
180
-                }
181
-            }
182
-        }
183
-
184
-        // for each indentified action, we have to clean up the begin and the end of the texte
185
-        // based on tags that surround it
186
-
187
-        // list of the tags to clean
188
-        $tagsToClean = array(
189
-            'page', 'page_header', 'page_footer', 'form',
190
-            'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br',
191
-            'div', 'hr', 'p', 'ul', 'ol', 'li',
192
-            'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
193
-            'bookmark', 'fieldset', 'legend',
194
-            'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline',
195
-            'option'
196
-        );
197
-
198
-        // foreach action
199
-        $nb = count($actions);
200
-        for ($k=0; $k<$nb; $k++) {
201
-            // if it is a Text
202
-            if ($actions[$k]['name']=='write') {
203
-                // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
-                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206
-
207
-                // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
-                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210
-
211
-                // if the text is empty => remove the action
212
-                if (!strlen($actions[$k]['param']['txt']))
213
-                    unset($actions[$k]);
214
-            }
215
-        }
216
-
217
-        // if we are not on the level 0 => HTML validator ERROR
218
-        if (count($parents)) throw new HTML2PDF_exception(5, $parents);
219
-
220
-        // save the actions to do
221
-        $this->code = array_values($actions);
222
-    }
223
-
224
-    /**
225
-     * prepare the text
226
-     *
227
-     * @param   string texte
228
-     * @param   boolean true => replace multiple space+\t+\r+\n by a single space
229
-     * @return  string texte
230
-     * @access  protected
231
-     */
232
-    protected function _prepareTxt($txt, $spaces = true)
233
-    {
234
-        if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
235
-        $txt = str_replace('&euro;', '€', $txt);
236
-        $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237
-        return $txt;
238
-    }
239
-
240
-    /**
241
-     * parse the HTML code
242
-     *
243
-     * @param    &array    array's result
244
-     * @return   null
245
-     */
246
-    protected function _searchCode(&$tmp)
247
-    {
248
-        // initialise the array
249
-        $tmp = array();
250
-
251
-        // regexp to separate the tags from the texts
252
-        $reg = '/(<[^>]+>)|([^<]+)+/isU';
253
-
254
-        // last match found
255
-        $str = '';
256
-        $offset = 0;
257
-
258
-        // As it finds a match
259
-        while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) {
260
-            // if it is a tag
261
-            if ($parse[1][0]) {
262
-                // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
264
-
265
-                // save the tag, with the offset
266
-                $tmp[] = array('code', trim($parse[1][0]), $offset);
267
-
268
-                // init the current text
269
-                $str = '';
270
-            } else { // else (if it is a text)
271
-                // add the new text to the current text
272
-                $str.= $parse[2][0];
273
-            }
274
-
275
-            // Update offset to the end of the match
276
-            $offset = $parse[0][1] + strlen($parse[0][0]);
277
-            unset($parse);
278
-        }
279
-        // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
281
-        unset($str);
282
-    }
283
-
284
-    /**
285
-     * analise a HTML tag
286
-     *
287
-     * @param   string   HTML code to analise
288
-     * @return  array    corresponding action
289
-     */
290
-    protected function _analiseCode($code)
291
-    {
292
-        // name of the tag, opening, closure, autoclosure
293
-        $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
-        $close     = ($match[1]=='/' ? true : false);
296
-        $autoclose = preg_match('/\/>$/isU', $code);
297
-        $name      = strtolower($match[2]);
298
-
299
-        // required parameters (depends on the tag name)
300
-        $param    = array();
301
-        $param['style'] = '';
302
-        if ($name=='img') {
303
-            $param['alt'] = '';
304
-            $param['src'] = '';
305
-        }
306
-        if ($name=='a') {
307
-            $param['href'] = '';
308
-        }
309
-
310
-        // read the parameters : nom=valeur
311
-        $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
-        preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
314
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315
-
316
-        // read the parameters : nom="valeur"
317
-        $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
-        preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
320
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321
-
322
-        // read the parameters : nom='valeur'
323
-        $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
-        preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
326
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327
-
328
-        // compliance of each parameter
329
-        $color  = "#000000";
330
-        $border = null;
331
-        foreach ($param as $key => $val) {
332
-            $key = strtolower($key);
333
-            switch($key)
334
-            {
335
-                case 'width':
336
-                    unset($param[$key]);
337
-                    $param['style'] .= 'width: '.$val.'px; ';
338
-                    break;
339
-
340
-                case 'align':
341
-                    if ($name==='img') {
342
-                        unset($param[$key]);
343
-                        $param['style'] .= 'float: '.$val.'; ';
344
-                    } elseif ($name!=='table') {
345
-                        unset($param[$key]);
346
-                        $param['style'] .= 'text-align: '.$val.'; ';
347
-                    }
348
-                    break;
349
-
350
-                case 'valign':
351
-                    unset($param[$key]);
352
-                    $param['style'] .= 'vertical-align: '.$val.'; ';
353
-                    break;
354
-
355
-                case 'height':
356
-                    unset($param[$key]);
357
-                    $param['style'] .= 'height: '.$val.'px; ';
358
-                    break;
359
-
360
-                case 'bgcolor':
361
-                    unset($param[$key]);
362
-                    $param['style'] .= 'background: '.$val.'; ';
363
-                    break;
364
-
365
-                case 'bordercolor':
366
-                    unset($param[$key]);
367
-                    $color = $val;
368
-                    break;
369
-
370
-                case 'border':
371
-                    unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
373
-                    $border = $val;
374
-                    break;
375
-
376
-                case 'cellpadding':
377
-                case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
379
-                    break;
380
-
381
-                case 'colspan':
382
-                case 'rowspan':
383
-                    $val = preg_replace('/[^0-9]/isU', '', $val);
384
-                    if (!$val) $val = 1;
385
-                    $param[$key] = $val;
386
-                    break;
387
-            }
388
-        }
389
-
390
-        // compliance of the border
391
-        if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
393
-            else            $border = 'border: none';
394
-
395
-            $param['style'] .= $border.'; ';
396
-            $param['border'] = $border;
397
-        }
398
-
399
-        // reading styles: decomposition and standardization
400
-        $styles = explode(';', $param['style']);
401
-        $param['style'] = array();
402
-        foreach ($styles as $style) {
403
-            $tmp = explode(':', $style);
404
-            if (count($tmp)>1) {
405
-                $cod = $tmp[0];
406
-                unset($tmp[0]);
407
-                $tmp = implode(':', $tmp);
408
-                $param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp));
409
-            }
410
-        }
411
-
412
-        // determining the level of table opening, with an added level
413
-        if (in_array($name, array('ul', 'ol', 'table')) && !$close) {
414
-            $this->_num++;
415
-            $this->_level[count($this->_level)] = $this->_num;
416
-        }
417
-
418
-        // get the level of the table containing the element
419
-        if (!isset($param['num'])) {
420
-            $param['num'] = $this->_level[count($this->_level)-1];
421
-        }
422
-
423
-        // for closures table: remove a level
424
-        if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
-            unset($this->_level[count($this->_level)-1]);
426
-        }
427
-
428
-        // prepare the parameters
429
-        if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
-        if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
-        if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
-        if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
433
-
434
-        // return the new action to do
435
-        return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
436
-    }
437
-
438
-    /**
439
-     * get a full level of HTML, between an opening and closing corresponding
440
-     *
441
-     * @param   integer key
442
-     * @return  array   actions
443
-     */
444
-    public function getLevel($k)
445
-    {
446
-        // if the code does not exist => return empty
447
-        if (!isset($this->code[$k])) return array();
448
-
449
-        // the tag to detect
450
-        $detect = $this->code[$k]['name'];
451
-
452
-        // if it is a text => return
453
-        if ($detect=='write') {
454
-            return array($this->code[$k]);
455
-        }
456
-
457
-        //
458
-        $level = 0;      // depth level
459
-        $end = false;    // end of the search
460
-        $code = array(); // extract code
461
-
462
-        // while it's not ended
463
-        while (!$end) {
464
-            // current action
465
-            $row = $this->code[$k];
466
-
467
-            // if 'write' => we add the text
468
-            if ($row['name']=='write') {
469
-                $code[] = $row;
470
-            } else { // else, it is a html tag
471
-                $not = false; // flag for not taking into account the current tag
472
-
473
-                // if it is the searched tag
474
-                if ($row['name']==$detect) {
475
-                    // if we are just at the root level => dont take it
476
-                    if ($level==0) {
477
-                        $not = true;
478
-                    }
479
-
480
-                    // update the level
481
-                    $level+= ($row['close'] ? -1 : 1);
482
-
483
-                    // if we are now at the root level => it is the end, and dont take it
484
-                    if ($level==0) {
485
-                        $not = true;
486
-                        $end = true;
487
-                    }
488
-                }
489
-
490
-                // if we can takin into account the current tag => save it
491
-                if (!$not) {
492
-                    if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
493
-                    $code[] = $row;
494
-                }
495
-            }
496
-
497
-            // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
499
-                $k++;
500
-            else
501
-                $end = true;
502
-        }
503
-
504
-        // return the extract
505
-        return $code;
506
-    }
507
-
508
-    /**
509
-     * return a part of the HTML code, for error message
510
-     *
511
-     * @param   integer position
512
-     * @param   integer take before
513
-     * @param   integer take after
514
-     * @return  string  part of the html code
515
-     */
516
-    public function getHtmlErrorCode($pos, $before=30, $after=40)
517
-    {
518
-        return substr($this->_html, $pos-$before, $before+$after);
519
-    }
14
+	protected    $_html     = '';        // HTML code to parse
15
+	protected    $_num      = 0;         // table number
16
+	protected    $_level    = 0;         // table level
17
+	protected    $_encoding = '';        // encoding
18
+	public       $code      = array();   // parsed HTML codfe
19
+
20
+	const HTML_TAB = '        ';
21
+
22
+	/**
23
+	 * main constructor
24
+	 *
25
+	 * @param   string encoding
26
+	 * @access  public
27
+	 */
28
+	public function __construct($encoding = 'UTF-8')
29
+	{
30
+		$this->_num   = 0;
31
+		$this->_level = array($this->_num);
32
+		$this->_html  = '';
33
+		$this->code  = array();
34
+		$this->setEncoding($encoding);
35
+	}
36
+
37
+	/**
38
+	 * change the encoding
39
+	 *
40
+	 * @param   string encoding
41
+	 * @access  public
42
+	 */
43
+	public function setEncoding($encoding)
44
+	{
45
+		$this->_encoding = $encoding;
46
+	}
47
+
48
+	/**
49
+	 * Define the HTML code to parse
50
+	 *
51
+	 * @param   string HTML code
52
+	 * @access  public
53
+	 */
54
+	public function setHTML($html)
55
+	{
56
+		// remove the HTML in comment
57
+		$html = preg_replace('/<!--(.*)-->/isU', '', $html);
58
+
59
+		// save the HTML code
60
+		$this->_html = $html;
61
+	}
62
+
63
+	/**
64
+	 * parse the HTML code
65
+	 *
66
+	 * @access public
67
+	 */
68
+	public function parse()
69
+	{
70
+		$parents = array();
71
+
72
+		// flag : are we in a <pre> Tag ?
73
+		$tagPreIn = false;
74
+
75
+		// action to use for each line of the content of a <pre> Tag
76
+		$tagPreBr = array(
77
+					'name' => 'br',
78
+					'close' => false,
79
+					'param' => array(
80
+						'style' => array(),
81
+						'num'    => 0
82
+					)
83
+				);
84
+
85
+		// tag that can be not closed
86
+		$tagsNotClosed = array(
87
+			'br', 'hr', 'img', 'col',
88
+			'input', 'link', 'option',
89
+			'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline'
90
+		);
91
+
92
+		// search the HTML tags
93
+		$tmp = array();
94
+		$this->_searchCode($tmp);
95
+
96
+		// all the actions to do
97
+		$actions = array();
98
+
99
+		// foreach part of the HTML code
100
+		foreach ($tmp as $part) {
101
+			// if it is a tag code
102
+			if ($part[0]=='code') {
103
+				// analise the HTML code
104
+				$res = $this->_analiseCode($part[1]);
105
+
106
+				// if it is a real HTML tag
107
+				if ($res) {
108
+					// save the current posistion in the HTML code
109
+					$res['html_pos'] = $part[2];
110
+
111
+					// if the tag must be closed
112
+					if (!in_array($res['name'], $tagsNotClosed)) {
113
+						// if it is a closure tag
114
+						if ($res['close']) {
115
+							// HTML validation
116
+							if (count($parents)<1)
117
+								throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
+							else if ($parents[count($parents)-1]!=$res['name'])
119
+								throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
+							else
121
+								unset($parents[count($parents)-1]);
122
+						} else {
123
+							// if it is a autoclosed tag
124
+							if ($res['autoclose']) {
125
+								// save the opened tag
126
+								$actions[] = $res;
127
+
128
+								// prepare the closed tag
129
+								$res['params'] = array();
130
+								$res['close'] = true;
131
+							}
132
+							// else :add a child for validation
133
+							else
134
+								$parents[count($parents)] = $res['name'];
135
+						}
136
+
137
+						// if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
+						if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
139
+							$tagPreIn = !$res['close'];
140
+						}
141
+					}
142
+
143
+					// save the actions to convert
144
+					$actions[] = $res;
145
+				} else { // else (it is not a real HTML tag => we transform it in Texte
146
+					$part[0]='txt';
147
+				}
148
+			}
149
+			// if it is text
150
+			if ($part[0]=='txt') {
151
+				// if we are not in a <pre> tag
152
+				if (!$tagPreIn) {
153
+					// save the action
154
+					$actions[] = array(
155
+						'name'    => 'write',
156
+						'close'    => false,
157
+						'param' => array('txt' => $this->_prepareTxt($part[1])),
158
+					);
159
+				} else { // else (if we are in a <pre> tag)
160
+					// prepare the text
161
+					$part[1] = str_replace("\r", '', $part[1]);
162
+					$part[1] = explode("\n", $part[1]);
163
+
164
+					// foreach line of the text
165
+					foreach ($part[1] as $k => $txt) {
166
+						// transform the line
167
+						$txt = str_replace("\t", self::HTML_TAB, $txt);
168
+						$txt = str_replace(' ', '&nbsp;', $txt);
169
+
170
+						// add a break line
171
+						if ($k>0) $actions[] = $tagPreBr;
172
+
173
+						// save the action
174
+						$actions[] = array(
175
+							'name'    => 'write',
176
+							'close'    => false,
177
+							'param' => array('txt' => $this->_prepareTxt($txt, false)),
178
+						);
179
+					}
180
+				}
181
+			}
182
+		}
183
+
184
+		// for each indentified action, we have to clean up the begin and the end of the texte
185
+		// based on tags that surround it
186
+
187
+		// list of the tags to clean
188
+		$tagsToClean = array(
189
+			'page', 'page_header', 'page_footer', 'form',
190
+			'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br',
191
+			'div', 'hr', 'p', 'ul', 'ol', 'li',
192
+			'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
193
+			'bookmark', 'fieldset', 'legend',
194
+			'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline',
195
+			'option'
196
+		);
197
+
198
+		// foreach action
199
+		$nb = count($actions);
200
+		for ($k=0; $k<$nb; $k++) {
201
+			// if it is a Text
202
+			if ($actions[$k]['name']=='write') {
203
+				// if the tag before the text is a tag to clean => ltrim on the text
204
+				if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
+					$actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206
+
207
+				// if the tag after the text is a tag to clean => rtrim on the text
208
+				if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
+					$actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210
+
211
+				// if the text is empty => remove the action
212
+				if (!strlen($actions[$k]['param']['txt']))
213
+					unset($actions[$k]);
214
+			}
215
+		}
216
+
217
+		// if we are not on the level 0 => HTML validator ERROR
218
+		if (count($parents)) throw new HTML2PDF_exception(5, $parents);
219
+
220
+		// save the actions to do
221
+		$this->code = array_values($actions);
222
+	}
223
+
224
+	/**
225
+	 * prepare the text
226
+	 *
227
+	 * @param   string texte
228
+	 * @param   boolean true => replace multiple space+\t+\r+\n by a single space
229
+	 * @return  string texte
230
+	 * @access  protected
231
+	 */
232
+	protected function _prepareTxt($txt, $spaces = true)
233
+	{
234
+		if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
235
+		$txt = str_replace('&euro;', '€', $txt);
236
+		$txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237
+		return $txt;
238
+	}
239
+
240
+	/**
241
+	 * parse the HTML code
242
+	 *
243
+	 * @param    &array    array's result
244
+	 * @return   null
245
+	 */
246
+	protected function _searchCode(&$tmp)
247
+	{
248
+		// initialise the array
249
+		$tmp = array();
250
+
251
+		// regexp to separate the tags from the texts
252
+		$reg = '/(<[^>]+>)|([^<]+)+/isU';
253
+
254
+		// last match found
255
+		$str = '';
256
+		$offset = 0;
257
+
258
+		// As it finds a match
259
+		while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) {
260
+			// if it is a tag
261
+			if ($parse[1][0]) {
262
+				// save the previous text if it exists
263
+				if ($str!=='')    $tmp[] = array('txt', $str);
264
+
265
+				// save the tag, with the offset
266
+				$tmp[] = array('code', trim($parse[1][0]), $offset);
267
+
268
+				// init the current text
269
+				$str = '';
270
+			} else { // else (if it is a text)
271
+				// add the new text to the current text
272
+				$str.= $parse[2][0];
273
+			}
274
+
275
+			// Update offset to the end of the match
276
+			$offset = $parse[0][1] + strlen($parse[0][0]);
277
+			unset($parse);
278
+		}
279
+		// if a text is present in the end, we save it
280
+		if ($str!='') $tmp[] = array('txt', $str);
281
+		unset($str);
282
+	}
283
+
284
+	/**
285
+	 * analise a HTML tag
286
+	 *
287
+	 * @param   string   HTML code to analise
288
+	 * @return  array    corresponding action
289
+	 */
290
+	protected function _analiseCode($code)
291
+	{
292
+		// name of the tag, opening, closure, autoclosure
293
+		$tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
+		if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
+		$close     = ($match[1]=='/' ? true : false);
296
+		$autoclose = preg_match('/\/>$/isU', $code);
297
+		$name      = strtolower($match[2]);
298
+
299
+		// required parameters (depends on the tag name)
300
+		$param    = array();
301
+		$param['style'] = '';
302
+		if ($name=='img') {
303
+			$param['alt'] = '';
304
+			$param['src'] = '';
305
+		}
306
+		if ($name=='a') {
307
+			$param['href'] = '';
308
+		}
309
+
310
+		// read the parameters : nom=valeur
311
+		$prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
+		preg_match_all('/'.$prop.'/is', $code, $match);
313
+		for($k=0; $k<count($match[0]); $k++)
314
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315
+
316
+		// read the parameters : nom="valeur"
317
+		$prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
+		preg_match_all('/'.$prop.'/is', $code, $match);
319
+		for($k=0; $k<count($match[0]); $k++)
320
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321
+
322
+		// read the parameters : nom='valeur'
323
+		$prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
+		preg_match_all('/'.$prop.'/is', $code, $match);
325
+		for($k=0; $k<count($match[0]); $k++)
326
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327
+
328
+		// compliance of each parameter
329
+		$color  = "#000000";
330
+		$border = null;
331
+		foreach ($param as $key => $val) {
332
+			$key = strtolower($key);
333
+			switch($key)
334
+			{
335
+				case 'width':
336
+					unset($param[$key]);
337
+					$param['style'] .= 'width: '.$val.'px; ';
338
+					break;
339
+
340
+				case 'align':
341
+					if ($name==='img') {
342
+						unset($param[$key]);
343
+						$param['style'] .= 'float: '.$val.'; ';
344
+					} elseif ($name!=='table') {
345
+						unset($param[$key]);
346
+						$param['style'] .= 'text-align: '.$val.'; ';
347
+					}
348
+					break;
349
+
350
+				case 'valign':
351
+					unset($param[$key]);
352
+					$param['style'] .= 'vertical-align: '.$val.'; ';
353
+					break;
354
+
355
+				case 'height':
356
+					unset($param[$key]);
357
+					$param['style'] .= 'height: '.$val.'px; ';
358
+					break;
359
+
360
+				case 'bgcolor':
361
+					unset($param[$key]);
362
+					$param['style'] .= 'background: '.$val.'; ';
363
+					break;
364
+
365
+				case 'bordercolor':
366
+					unset($param[$key]);
367
+					$color = $val;
368
+					break;
369
+
370
+				case 'border':
371
+					unset($param[$key]);
372
+					if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
373
+					$border = $val;
374
+					break;
375
+
376
+				case 'cellpadding':
377
+				case 'cellspacing':
378
+					if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
379
+					break;
380
+
381
+				case 'colspan':
382
+				case 'rowspan':
383
+					$val = preg_replace('/[^0-9]/isU', '', $val);
384
+					if (!$val) $val = 1;
385
+					$param[$key] = $val;
386
+					break;
387
+			}
388
+		}
389
+
390
+		// compliance of the border
391
+		if ($border!==null) {
392
+			if ($border)    $border = 'border: solid '.$border.' '.$color;
393
+			else            $border = 'border: none';
394
+
395
+			$param['style'] .= $border.'; ';
396
+			$param['border'] = $border;
397
+		}
398
+
399
+		// reading styles: decomposition and standardization
400
+		$styles = explode(';', $param['style']);
401
+		$param['style'] = array();
402
+		foreach ($styles as $style) {
403
+			$tmp = explode(':', $style);
404
+			if (count($tmp)>1) {
405
+				$cod = $tmp[0];
406
+				unset($tmp[0]);
407
+				$tmp = implode(':', $tmp);
408
+				$param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp));
409
+			}
410
+		}
411
+
412
+		// determining the level of table opening, with an added level
413
+		if (in_array($name, array('ul', 'ol', 'table')) && !$close) {
414
+			$this->_num++;
415
+			$this->_level[count($this->_level)] = $this->_num;
416
+		}
417
+
418
+		// get the level of the table containing the element
419
+		if (!isset($param['num'])) {
420
+			$param['num'] = $this->_level[count($this->_level)-1];
421
+		}
422
+
423
+		// for closures table: remove a level
424
+		if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
+			unset($this->_level[count($this->_level)-1]);
426
+		}
427
+
428
+		// prepare the parameters
429
+		if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
+		if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
+		if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
+		if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
433
+
434
+		// return the new action to do
435
+		return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
436
+	}
437
+
438
+	/**
439
+	 * get a full level of HTML, between an opening and closing corresponding
440
+	 *
441
+	 * @param   integer key
442
+	 * @return  array   actions
443
+	 */
444
+	public function getLevel($k)
445
+	{
446
+		// if the code does not exist => return empty
447
+		if (!isset($this->code[$k])) return array();
448
+
449
+		// the tag to detect
450
+		$detect = $this->code[$k]['name'];
451
+
452
+		// if it is a text => return
453
+		if ($detect=='write') {
454
+			return array($this->code[$k]);
455
+		}
456
+
457
+		//
458
+		$level = 0;      // depth level
459
+		$end = false;    // end of the search
460
+		$code = array(); // extract code
461
+
462
+		// while it's not ended
463
+		while (!$end) {
464
+			// current action
465
+			$row = $this->code[$k];
466
+
467
+			// if 'write' => we add the text
468
+			if ($row['name']=='write') {
469
+				$code[] = $row;
470
+			} else { // else, it is a html tag
471
+				$not = false; // flag for not taking into account the current tag
472
+
473
+				// if it is the searched tag
474
+				if ($row['name']==$detect) {
475
+					// if we are just at the root level => dont take it
476
+					if ($level==0) {
477
+						$not = true;
478
+					}
479
+
480
+					// update the level
481
+					$level+= ($row['close'] ? -1 : 1);
482
+
483
+					// if we are now at the root level => it is the end, and dont take it
484
+					if ($level==0) {
485
+						$not = true;
486
+						$end = true;
487
+					}
488
+				}
489
+
490
+				// if we can takin into account the current tag => save it
491
+				if (!$not) {
492
+					if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
493
+					$code[] = $row;
494
+				}
495
+			}
496
+
497
+			// it continues as long as there has code to analise
498
+			if (isset($this->code[$k+1]))
499
+				$k++;
500
+			else
501
+				$end = true;
502
+		}
503
+
504
+		// return the extract
505
+		return $code;
506
+	}
507
+
508
+	/**
509
+	 * return a part of the HTML code, for error message
510
+	 *
511
+	 * @param   integer position
512
+	 * @param   integer take before
513
+	 * @param   integer take after
514
+	 * @return  string  part of the html code
515
+	 */
516
+	public function getHtmlErrorCode($pos, $before=30, $after=40)
517
+	{
518
+		return substr($this->_html, $pos-$before, $before+$after);
519
+	}
520 520
 }
521 521
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - parsingHtml class
4 4
  *
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingHtml
13 13
 {
14
-    protected    $_html     = '';        // HTML code to parse
15
-    protected    $_num      = 0;         // table number
16
-    protected    $_level    = 0;         // table level
17
-    protected    $_encoding = '';        // encoding
18
-    public       $code      = array();   // parsed HTML codfe
14
+    protected    $_html     = ''; // HTML code to parse
15
+    protected    $_num      = 0; // table number
16
+    protected    $_level    = 0; // table level
17
+    protected    $_encoding = ''; // encoding
18
+    public       $code      = array(); // parsed HTML codfe
19 19
 
20 20
     const HTML_TAB = '        ';
21 21
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $this->_num   = 0;
31 31
         $this->_level = array($this->_num);
32 32
         $this->_html  = '';
33
-        $this->code  = array();
33
+        $this->code = array();
34 34
         $this->setEncoding($encoding);
35 35
     }
36 36
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         // foreach part of the HTML code
100 100
         foreach ($tmp as $part) {
101 101
             // if it is a tag code
102
-            if ($part[0]=='code') {
102
+            if ($part[0] == 'code') {
103 103
                 // analise the HTML code
104 104
                 $res = $this->_analiseCode($part[1]);
105 105
 
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
                         // if it is a closure tag
114 114
                         if ($res['close']) {
115 115
                             // HTML validation
116
-                            if (count($parents)<1)
116
+                            if (count($parents) < 1)
117 117
                                 throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
118
+                            else if ($parents[count($parents) - 1] != $res['name'])
119 119
                                 throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120 120
                             else
121
-                                unset($parents[count($parents)-1]);
121
+                                unset($parents[count($parents) - 1]);
122 122
                         } else {
123 123
                             // if it is a autoclosed tag
124 124
                             if ($res['autoclose']) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                         }
136 136
 
137 137
                         // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
-                        if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
138
+                        if (($res['name'] == 'pre' || $res['name'] == 'code') && !$res['autoclose']) {
139 139
                             $tagPreIn = !$res['close'];
140 140
                         }
141 141
                     }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
                     // save the actions to convert
144 144
                     $actions[] = $res;
145 145
                 } else { // else (it is not a real HTML tag => we transform it in Texte
146
-                    $part[0]='txt';
146
+                    $part[0] = 'txt';
147 147
                 }
148 148
             }
149 149
             // if it is text
150
-            if ($part[0]=='txt') {
150
+            if ($part[0] == 'txt') {
151 151
                 // if we are not in a <pre> tag
152 152
                 if (!$tagPreIn) {
153 153
                     // save the action
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                         $txt = str_replace(' ', '&nbsp;', $txt);
169 169
 
170 170
                         // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
171
+                        if ($k > 0) $actions[] = $tagPreBr;
172 172
 
173 173
                         // save the action
174 174
                         $actions[] = array(
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 
198 198
         // foreach action
199 199
         $nb = count($actions);
200
-        for ($k=0; $k<$nb; $k++) {
200
+        for ($k = 0; $k < $nb; $k++) {
201 201
             // if it is a Text
202
-            if ($actions[$k]['name']=='write') {
202
+            if ($actions[$k]['name'] == 'write') {
203 203
                 // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
204
+                if ($k > 0 && in_array($actions[$k - 1]['name'], $tagsToClean))
205 205
                     $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206 206
 
207 207
                 // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
208
+                if ($k < $nb - 1 && in_array($actions[$k + 1]['name'], $tagsToClean))
209 209
                     $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210 210
 
211 211
                 // if the text is empty => remove the action
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             // if it is a tag
261 261
             if ($parse[1][0]) {
262 262
                 // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
263
+                if ($str !== '')    $tmp[] = array('txt', $str);
264 264
 
265 265
                 // save the tag, with the offset
266 266
                 $tmp[] = array('code', trim($parse[1][0]), $offset);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 $str = '';
270 270
             } else { // else (if it is a text)
271 271
                 // add the new text to the current text
272
-                $str.= $parse[2][0];
272
+                $str .= $parse[2][0];
273 273
             }
274 274
 
275 275
             // Update offset to the end of the match
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             unset($parse);
278 278
         }
279 279
         // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
280
+        if ($str != '') $tmp[] = array('txt', $str);
281 281
         unset($str);
282 282
     }
283 283
 
@@ -291,38 +291,38 @@  discard block
 block discarded – undo
291 291
     {
292 292
         // name of the tag, opening, closure, autoclosure
293 293
         $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
-        $close     = ($match[1]=='/' ? true : false);
294
+        if (!preg_match('/' . $tag . '/isU', $code, $match)) return null;
295
+        $close     = ($match[1] == '/' ? true : false);
296 296
         $autoclose = preg_match('/\/>$/isU', $code);
297 297
         $name      = strtolower($match[2]);
298 298
 
299 299
         // required parameters (depends on the tag name)
300
-        $param    = array();
300
+        $param = array();
301 301
         $param['style'] = '';
302
-        if ($name=='img') {
302
+        if ($name == 'img') {
303 303
             $param['alt'] = '';
304 304
             $param['src'] = '';
305 305
         }
306
-        if ($name=='a') {
306
+        if ($name == 'a') {
307 307
             $param['href'] = '';
308 308
         }
309 309
 
310 310
         // read the parameters : nom=valeur
311 311
         $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
-        preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
312
+        preg_match_all('/' . $prop . '/is', $code, $match);
313
+        for ($k = 0; $k < count($match[0]); $k++)
314 314
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315 315
 
316 316
         // read the parameters : nom="valeur"
317 317
         $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
-        preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
318
+        preg_match_all('/' . $prop . '/is', $code, $match);
319
+        for ($k = 0; $k < count($match[0]); $k++)
320 320
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321 321
 
322 322
         // read the parameters : nom='valeur'
323 323
         $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
-        preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
324
+        preg_match_all('/' . $prop . '/is', $code, $match);
325
+        for ($k = 0; $k < count($match[0]); $k++)
326 326
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327 327
 
328 328
         // compliance of each parameter
@@ -330,36 +330,36 @@  discard block
 block discarded – undo
330 330
         $border = null;
331 331
         foreach ($param as $key => $val) {
332 332
             $key = strtolower($key);
333
-            switch($key)
333
+            switch ($key)
334 334
             {
335 335
                 case 'width':
336 336
                     unset($param[$key]);
337
-                    $param['style'] .= 'width: '.$val.'px; ';
337
+                    $param['style'] .= 'width: ' . $val . 'px; ';
338 338
                     break;
339 339
 
340 340
                 case 'align':
341
-                    if ($name==='img') {
341
+                    if ($name === 'img') {
342 342
                         unset($param[$key]);
343
-                        $param['style'] .= 'float: '.$val.'; ';
344
-                    } elseif ($name!=='table') {
343
+                        $param['style'] .= 'float: ' . $val . '; ';
344
+                    } elseif ($name !== 'table') {
345 345
                         unset($param[$key]);
346
-                        $param['style'] .= 'text-align: '.$val.'; ';
346
+                        $param['style'] .= 'text-align: ' . $val . '; ';
347 347
                     }
348 348
                     break;
349 349
 
350 350
                 case 'valign':
351 351
                     unset($param[$key]);
352
-                    $param['style'] .= 'vertical-align: '.$val.'; ';
352
+                    $param['style'] .= 'vertical-align: ' . $val . '; ';
353 353
                     break;
354 354
 
355 355
                 case 'height':
356 356
                     unset($param[$key]);
357
-                    $param['style'] .= 'height: '.$val.'px; ';
357
+                    $param['style'] .= 'height: ' . $val . 'px; ';
358 358
                     break;
359 359
 
360 360
                 case 'bgcolor':
361 361
                     unset($param[$key]);
362
-                    $param['style'] .= 'background: '.$val.'; ';
362
+                    $param['style'] .= 'background: ' . $val . '; ';
363 363
                     break;
364 364
 
365 365
                 case 'bordercolor':
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
                 case 'border':
371 371
                     unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
372
+                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val . 'px';
373 373
                     $border = $val;
374 374
                     break;
375 375
 
376 376
                 case 'cellpadding':
377 377
                 case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
378
+                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val . 'px';
379 379
                     break;
380 380
 
381 381
                 case 'colspan':
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
         }
389 389
 
390 390
         // compliance of the border
391
-        if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
391
+        if ($border !== null) {
392
+            if ($border)    $border = 'border: solid ' . $border . ' ' . $color;
393 393
             else            $border = 'border: none';
394 394
 
395
-            $param['style'] .= $border.'; ';
395
+            $param['style'] .= $border . '; ';
396 396
             $param['border'] = $border;
397 397
         }
398 398
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $param['style'] = array();
402 402
         foreach ($styles as $style) {
403 403
             $tmp = explode(':', $style);
404
-            if (count($tmp)>1) {
404
+            if (count($tmp) > 1) {
405 405
                 $cod = $tmp[0];
406 406
                 unset($tmp[0]);
407 407
                 $tmp = implode(':', $tmp);
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 
418 418
         // get the level of the table containing the element
419 419
         if (!isset($param['num'])) {
420
-            $param['num'] = $this->_level[count($this->_level)-1];
420
+            $param['num'] = $this->_level[count($this->_level) - 1];
421 421
         }
422 422
 
423 423
         // for closures table: remove a level
424 424
         if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
-            unset($this->_level[count($this->_level)-1]);
425
+            unset($this->_level[count($this->_level) - 1]);
426 426
         }
427 427
 
428 428
         // prepare the parameters
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
         $detect = $this->code[$k]['name'];
451 451
 
452 452
         // if it is a text => return
453
-        if ($detect=='write') {
453
+        if ($detect == 'write') {
454 454
             return array($this->code[$k]);
455 455
         }
456 456
 
457 457
         //
458
-        $level = 0;      // depth level
459
-        $end = false;    // end of the search
458
+        $level = 0; // depth level
459
+        $end = false; // end of the search
460 460
         $code = array(); // extract code
461 461
 
462 462
         // while it's not ended
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
             $row = $this->code[$k];
466 466
 
467 467
             // if 'write' => we add the text
468
-            if ($row['name']=='write') {
468
+            if ($row['name'] == 'write') {
469 469
                 $code[] = $row;
470 470
             } else { // else, it is a html tag
471 471
                 $not = false; // flag for not taking into account the current tag
472 472
 
473 473
                 // if it is the searched tag
474
-                if ($row['name']==$detect) {
474
+                if ($row['name'] == $detect) {
475 475
                     // if we are just at the root level => dont take it
476
-                    if ($level==0) {
476
+                    if ($level == 0) {
477 477
                         $not = true;
478 478
                     }
479 479
 
480 480
                     // update the level
481
-                    $level+= ($row['close'] ? -1 : 1);
481
+                    $level += ($row['close'] ? -1 : 1);
482 482
 
483 483
                     // if we are now at the root level => it is the end, and dont take it
484
-                    if ($level==0) {
484
+                    if ($level == 0) {
485 485
                         $not = true;
486 486
                         $end = true;
487 487
                     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
             }
496 496
 
497 497
             // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
498
+            if (isset($this->code[$k + 1]))
499 499
                 $k++;
500 500
             else
501 501
                 $end = true;
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
      * @param   integer take after
514 514
      * @return  string  part of the html code
515 515
      */
516
-    public function getHtmlErrorCode($pos, $before=30, $after=40)
516
+    public function getHtmlErrorCode($pos, $before = 30, $after = 40)
517 517
     {
518
-        return substr($this->_html, $pos-$before, $before+$after);
518
+        return substr($this->_html, $pos - $before, $before + $after);
519 519
     }
520 520
 }
521 521
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +86 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - parsingHtml class
4 6
  *
@@ -113,12 +115,13 @@  discard block
 block discarded – undo
113 115
                         // if it is a closure tag
114 116
                         if ($res['close']) {
115 117
                             // HTML validation
116
-                            if (count($parents)<1)
117
-                                throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
119
-                                throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
-                            else
121
-                                unset($parents[count($parents)-1]);
118
+                            if (count($parents)<1) {
119
+                                                            throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
120
+                            } else if ($parents[count($parents)-1]!=$res['name']) {
121
+                                                            throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
122
+                            } else {
123
+                                                            unset($parents[count($parents)-1]);
124
+                            }
122 125
                         } else {
123 126
                             // if it is a autoclosed tag
124 127
                             if ($res['autoclose']) {
@@ -130,8 +133,9 @@  discard block
 block discarded – undo
130 133
                                 $res['close'] = true;
131 134
                             }
132 135
                             // else :add a child for validation
133
-                            else
134
-                                $parents[count($parents)] = $res['name'];
136
+                            else {
137
+                                                            $parents[count($parents)] = $res['name'];
138
+                            }
135 139
                         }
136 140
 
137 141
                         // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
@@ -168,7 +172,9 @@  discard block
 block discarded – undo
168 172
                         $txt = str_replace(' ', '&nbsp;', $txt);
169 173
 
170 174
                         // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
175
+                        if ($k>0) {
176
+                        	$actions[] = $tagPreBr;
177
+                        }
172 178
 
173 179
                         // save the action
174 180
                         $actions[] = array(
@@ -201,21 +207,26 @@  discard block
 block discarded – undo
201 207
             // if it is a Text
202 208
             if ($actions[$k]['name']=='write') {
203 209
                 // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
-                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
210
+                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) {
211
+                                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
212
+                }
206 213
 
207 214
                 // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
-                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
215
+                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) {
216
+                                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
217
+                }
210 218
 
211 219
                 // if the text is empty => remove the action
212
-                if (!strlen($actions[$k]['param']['txt']))
213
-                    unset($actions[$k]);
220
+                if (!strlen($actions[$k]['param']['txt'])) {
221
+                                    unset($actions[$k]);
222
+                }
214 223
             }
215 224
         }
216 225
 
217 226
         // if we are not on the level 0 => HTML validator ERROR
218
-        if (count($parents)) throw new HTML2PDF_exception(5, $parents);
227
+        if (count($parents)) {
228
+        	throw new HTML2PDF_exception(5, $parents);
229
+        }
219 230
 
220 231
         // save the actions to do
221 232
         $this->code = array_values($actions);
@@ -231,7 +242,9 @@  discard block
 block discarded – undo
231 242
      */
232 243
     protected function _prepareTxt($txt, $spaces = true)
233 244
     {
234
-        if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
245
+        if ($spaces) {
246
+        	$txt = preg_replace('/\s+/is', ' ', $txt);
247
+        }
235 248
         $txt = str_replace('&euro;', '€', $txt);
236 249
         $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237 250
         return $txt;
@@ -260,7 +273,9 @@  discard block
 block discarded – undo
260 273
             // if it is a tag
261 274
             if ($parse[1][0]) {
262 275
                 // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
276
+                if ($str!=='') {
277
+                	$tmp[] = array('txt', $str);
278
+                }
264 279
 
265 280
                 // save the tag, with the offset
266 281
                 $tmp[] = array('code', trim($parse[1][0]), $offset);
@@ -277,7 +292,9 @@  discard block
 block discarded – undo
277 292
             unset($parse);
278 293
         }
279 294
         // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
295
+        if ($str!='') {
296
+        	$tmp[] = array('txt', $str);
297
+        }
281 298
         unset($str);
282 299
     }
283 300
 
@@ -291,7 +308,9 @@  discard block
 block discarded – undo
291 308
     {
292 309
         // name of the tag, opening, closure, autoclosure
293 310
         $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
311
+        if (!preg_match('/'.$tag.'/isU', $code, $match)) {
312
+        	return null;
313
+        }
295 314
         $close     = ($match[1]=='/' ? true : false);
296 315
         $autoclose = preg_match('/\/>$/isU', $code);
297 316
         $name      = strtolower($match[2]);
@@ -310,20 +329,23 @@  discard block
 block discarded – undo
310 329
         // read the parameters : nom=valeur
311 330
         $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312 331
         preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
314
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
332
+        for($k=0; $k<count($match[0]); $k++) {
333
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
334
+        }
315 335
 
316 336
         // read the parameters : nom="valeur"
317 337
         $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318 338
         preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
320
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
339
+        for($k=0; $k<count($match[0]); $k++) {
340
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
341
+        }
321 342
 
322 343
         // read the parameters : nom='valeur'
323 344
         $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324 345
         preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
326
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
346
+        for($k=0; $k<count($match[0]); $k++) {
347
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
348
+        }
327 349
 
328 350
         // compliance of each parameter
329 351
         $color  = "#000000";
@@ -369,19 +391,25 @@  discard block
 block discarded – undo
369 391
 
370 392
                 case 'border':
371 393
                     unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
394
+                    if (preg_match('/^[0-9]+$/isU', $val)) {
395
+                    	$val = $val.'px';
396
+                    }
373 397
                     $border = $val;
374 398
                     break;
375 399
 
376 400
                 case 'cellpadding':
377 401
                 case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
402
+                    if (preg_match('/^([0-9]+)$/isU', $val)) {
403
+                    	$param[$key] = $val.'px';
404
+                    }
379 405
                     break;
380 406
 
381 407
                 case 'colspan':
382 408
                 case 'rowspan':
383 409
                     $val = preg_replace('/[^0-9]/isU', '', $val);
384
-                    if (!$val) $val = 1;
410
+                    if (!$val) {
411
+                    	$val = 1;
412
+                    }
385 413
                     $param[$key] = $val;
386 414
                     break;
387 415
             }
@@ -389,8 +417,11 @@  discard block
 block discarded – undo
389 417
 
390 418
         // compliance of the border
391 419
         if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
393
-            else            $border = 'border: none';
420
+            if ($border) {
421
+            	$border = 'border: solid '.$border.' '.$color;
422
+            } else {
423
+            	$border = 'border: none';
424
+            }
394 425
 
395 426
             $param['style'] .= $border.'; ';
396 427
             $param['border'] = $border;
@@ -426,10 +457,18 @@  discard block
 block discarded – undo
426 457
         }
427 458
 
428 459
         // prepare the parameters
429
-        if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
-        if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
-        if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
-        if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
460
+        if (isset($param['value'])) {
461
+        	$param['value']  = $this->_prepareTxt($param['value']);
462
+        }
463
+        if (isset($param['alt'])) {
464
+        	$param['alt']    = $this->_prepareTxt($param['alt']);
465
+        }
466
+        if (isset($param['title'])) {
467
+        	$param['title']  = $this->_prepareTxt($param['title']);
468
+        }
469
+        if (isset($param['class'])) {
470
+        	$param['class']  = $this->_prepareTxt($param['class']);
471
+        }
433 472
 
434 473
         // return the new action to do
435 474
         return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
@@ -444,7 +483,9 @@  discard block
 block discarded – undo
444 483
     public function getLevel($k)
445 484
     {
446 485
         // if the code does not exist => return empty
447
-        if (!isset($this->code[$k])) return array();
486
+        if (!isset($this->code[$k])) {
487
+        	return array();
488
+        }
448 489
 
449 490
         // the tag to detect
450 491
         $detect = $this->code[$k]['name'];
@@ -489,16 +530,19 @@  discard block
 block discarded – undo
489 530
 
490 531
                 // if we can takin into account the current tag => save it
491 532
                 if (!$not) {
492
-                    if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
533
+                    if (isset($row['style']['text-align'])) {
534
+                    	unset($row['style']['text-align']);
535
+                    }
493 536
                     $code[] = $row;
494 537
                 }
495 538
             }
496 539
 
497 540
             // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
499
-                $k++;
500
-            else
501
-                $end = true;
541
+            if (isset($this->code[$k+1])) {
542
+                            $k++;
543
+            } else {
544
+                            $end = true;
545
+            }
502 546
         }
503 547
 
504 548
         // return the extract
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_tcpdf_5.0.002/barcodes.php 4 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	/**
326 326
 	 * Encode a string to be used for CODE 39 Extended mode.
327 327
 	 * @param string $code code to represent.
328
-	 * @return encoded string.
328
+	 * @return false|string string.
329 329
 	 * @access protected
330 330
 	 */
331 331
 	protected function encode_code39_ext($code) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * Calculate CODE 39 checksum (modulo 43).
378 378
 	 * @param string $code code to represent.
379
-	 * @return char checksum.
379
+	 * @return string checksum.
380 380
 	 * @access protected
381 381
 	 */
382 382
 	protected function checksum_code39($code) {
@@ -399,7 +399,6 @@  discard block
 block discarded – undo
399 399
 	 * CODE 93 - USS-93
400 400
 	 * Compact code similar to Code 39
401 401
 	 * @param string $code code to represent.
402
-	 * @param boolean $checksum if true add a checksum to the code
403 402
 	 * @return array barcode representation.
404 403
 	 * @access protected
405 404
 	 */
@@ -988,7 +987,7 @@  discard block
 block discarded – undo
988 987
 	 * UPC-A: Universal product code seen on almost all retail products in the USA and Canada
989 988
 	 * UPC-E: Short version of UPC symbol
990 989
 	 * @param string $code code to represent.
991
-	 * @param string $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
990
+	 * @param integer $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
992 991
 	 * @return array barcode representation.
993 992
 	 * @access protected
994 993
 	 */
@@ -1181,7 +1180,7 @@  discard block
 block discarded – undo
1181 1180
 	 * 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers
1182 1181
 	 * 5-Digit Ext.: Used to mark suggested retail price of books
1183 1182
 	 * @param string $code code to represent.
1184
-	 * @param string $len barcode type: 2 = 2-Digit, 5 = 5-Digit
1183
+	 * @param integer $len barcode type: 2 = 2-Digit, 5 = 5-Digit
1185 1184
 	 * @return array barcode representation.
1186 1185
 	 * @access protected
1187 1186
 	 */
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
  */
52 52
 
53 53
 	/**
54
-	* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
55
-	* @name TCPDFBarcode
56
-	* @package com.tecnick.tcpdf
57
-	* @version 1.0.008
58
-	* @author Nicola Asuni
59
-	* @link http://www.tcpdf.org
60
-	* @license http://www.gnu.org/copyleft/lesser.html LGPL
61
-	*/
54
+	 * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
55
+	 * @name TCPDFBarcode
56
+	 * @package com.tecnick.tcpdf
57
+	 * @version 1.0.008
58
+	 * @author Nicola Asuni
59
+	 * @link http://www.tcpdf.org
60
+	 * @license http://www.gnu.org/copyleft/lesser.html LGPL
61
+	 */
62 62
 class TCPDFBarcode {
63 63
 	
64 64
 	/**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * <li>$arrcode['bcode'][$k]['h'] bar height in units.</li>
80 80
 	 * <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul>
81 81
 	 * @param string $code code to print
82
- 	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
82
+	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
83 83
 	 */
84 84
 	public function __construct($code, $type) {
85 85
 		$this->setBarcode($code, $type);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	
88 88
 	/** 
89 89
 	 * Return an array representations of barcode.
90
- 	 * @return array
90
+	 * @return array
91 91
 	 */
92 92
 	public function getBarcodeArray() {
93 93
 		return $this->barcode_array;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	/** 
97 97
 	 * Set the barcode.
98 98
 	 * @param string $code code to print
99
- 	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
100
- 	 * @return array
99
+	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
100
+	 * @return array
101 101
 	 */
102 102
 	public function setBarcode($code, $type) {
103 103
 		switch (strtoupper($type)) {
Please login to merge, or discard this patch.
Spacing   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : barcodes.php
4 4
 // Begin       : 2008-06-09
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @return array barcode representation.
235 235
 	 * @access protected
236 236
 	 */
237
-	protected function barcode_code39($code, $extended=false, $checksum=false) {
237
+	protected function barcode_code39($code, $extended = false, $checksum = false) {
238 238
 		$chr['0'] = '111221211';
239 239
 		$chr['1'] = '211211112';
240 240
 		$chr['2'] = '112211112';
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 			$code .= $this->checksum_code39($code);
294 294
 		}
295 295
 		// add start and stop codes
296
-		$code = '*'.$code.'*';
296
+		$code = '*' . $code . '*';
297 297
 		
298 298
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
299 299
 		$k = 0;
300 300
 		$clen = strlen($code);
301 301
 		for ($i = 0; $i < $clen; ++$i) {
302 302
 			$char = $code{$i};
303
-			if(!isset($chr[$char])) {
303
+			if (!isset($chr[$char])) {
304 304
 				// invalid character
305 305
 				return false;
306 306
 			}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 			chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
365 365
 		$code_ext = '';
366 366
 		$clen = strlen($code);
367
-		for ($i = 0 ; $i < $clen; ++$i) {
367
+		for ($i = 0; $i < $clen; ++$i) {
368 368
 			if (ord($code{$i}) > 127) {
369 369
 				return false;
370 370
 			}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
388 388
 		$sum = 0;
389 389
 		$clen = strlen($code);
390
-		for ($i = 0 ; $i < $clen; ++$i) {
390
+		for ($i = 0; $i < $clen; ++$i) {
391 391
 			$k = array_keys($chars, $code{$i});
392 392
 			$sum += $k[0];
393 393
 		}
@@ -454,41 +454,41 @@  discard block
 block discarded – undo
454 454
 		$chr['*'] = '111141';
455 455
 		$code = strtoupper($code);
456 456
 		$encode = array(
457
-			chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
458
-			chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
459
-			chr(8) => chr(128).'H', chr(9) => chr(128).'I', chr(10) => chr(128).'J', chr(11) => '£K',
460
-			chr(12) => chr(128).'L', chr(13) => chr(128).'M', chr(14) => chr(128).'N', chr(15) => chr(128).'O',
461
-			chr(16) => chr(128).'P', chr(17) => chr(128).'Q', chr(18) => chr(128).'R', chr(19) => chr(128).'S',
462
-			chr(20) => chr(128).'T', chr(21) => chr(128).'U', chr(22) => chr(128).'V', chr(23) => chr(128).'W',
463
-			chr(24) => chr(128).'X', chr(25) => chr(128).'Y', chr(26) => chr(128).'Z', chr(27) => chr(131).'A',
464
-			chr(28) => chr(131).'B', chr(29) => chr(131).'C', chr(30) => chr(131).'D', chr(31) => chr(131).'E',
465
-			chr(32) => ' ', chr(33) => chr(129).'A', chr(34) => chr(129).'B', chr(35) => chr(129).'C',
466
-			chr(36) => chr(129).'D', chr(37) => chr(129).'E', chr(38) => chr(129).'F', chr(39) => chr(129).'G',
467
-			chr(40) => chr(129).'H', chr(41) => chr(129).'I', chr(42) => chr(129).'J', chr(43) => chr(129).'K',
468
-			chr(44) => chr(129).'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129).'O',
457
+			chr(0) => chr(131) . 'U', chr(1) => chr(128) . 'A', chr(2) => chr(128) . 'B', chr(3) => chr(128) . 'C',
458
+			chr(4) => chr(128) . 'D', chr(5) => chr(128) . 'E', chr(6) => chr(128) . 'F', chr(7) => chr(128) . 'G',
459
+			chr(8) => chr(128) . 'H', chr(9) => chr(128) . 'I', chr(10) => chr(128) . 'J', chr(11) => '£K',
460
+			chr(12) => chr(128) . 'L', chr(13) => chr(128) . 'M', chr(14) => chr(128) . 'N', chr(15) => chr(128) . 'O',
461
+			chr(16) => chr(128) . 'P', chr(17) => chr(128) . 'Q', chr(18) => chr(128) . 'R', chr(19) => chr(128) . 'S',
462
+			chr(20) => chr(128) . 'T', chr(21) => chr(128) . 'U', chr(22) => chr(128) . 'V', chr(23) => chr(128) . 'W',
463
+			chr(24) => chr(128) . 'X', chr(25) => chr(128) . 'Y', chr(26) => chr(128) . 'Z', chr(27) => chr(131) . 'A',
464
+			chr(28) => chr(131) . 'B', chr(29) => chr(131) . 'C', chr(30) => chr(131) . 'D', chr(31) => chr(131) . 'E',
465
+			chr(32) => ' ', chr(33) => chr(129) . 'A', chr(34) => chr(129) . 'B', chr(35) => chr(129) . 'C',
466
+			chr(36) => chr(129) . 'D', chr(37) => chr(129) . 'E', chr(38) => chr(129) . 'F', chr(39) => chr(129) . 'G',
467
+			chr(40) => chr(129) . 'H', chr(41) => chr(129) . 'I', chr(42) => chr(129) . 'J', chr(43) => chr(129) . 'K',
468
+			chr(44) => chr(129) . 'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129) . 'O',
469 469
 			chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
470 470
 			chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
471
-			chr(56) => '8', chr(57) => '9', chr(58) => chr(129).'Z', chr(59) => chr(131).'F',
472
-			chr(60) => chr(131).'G', chr(61) => chr(131).'H', chr(62) => chr(131).'I', chr(63) => chr(131).'J',
473
-			chr(64) => chr(131).'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
471
+			chr(56) => '8', chr(57) => '9', chr(58) => chr(129) . 'Z', chr(59) => chr(131) . 'F',
472
+			chr(60) => chr(131) . 'G', chr(61) => chr(131) . 'H', chr(62) => chr(131) . 'I', chr(63) => chr(131) . 'J',
473
+			chr(64) => chr(131) . 'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
474 474
 			chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
475 475
 			chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
476 476
 			chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
477 477
 			chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
478 478
 			chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
479
-			chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131).'K',
480
-			chr(92) => chr(131).'L', chr(93) => chr(131).'M', chr(94) => chr(131).'N', chr(95) => chr(131).'O',
481
-			chr(96) => chr(131).'W', chr(97) => chr(130).'A', chr(98) => chr(130).'B', chr(99) => chr(130).'C',
482
-			chr(100) => chr(130).'D', chr(101) => chr(130).'E', chr(102) => chr(130).'F', chr(103) => chr(130).'G',
483
-			chr(104) => chr(130).'H', chr(105) => chr(130).'I', chr(106) => chr(130).'J', chr(107) => chr(130).'K',
484
-			chr(108) => chr(130).'L', chr(109) => chr(130).'M', chr(110) => chr(130).'N', chr(111) => chr(130).'O',
485
-			chr(112) => chr(130).'P', chr(113) => chr(130).'Q', chr(114) => chr(130).'R', chr(115) => chr(130).'S',
486
-			chr(116) => chr(130).'T', chr(117) => chr(130).'U', chr(118) => chr(130).'V', chr(119) => chr(130).'W',
487
-			chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
488
-			chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
479
+			chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131) . 'K',
480
+			chr(92) => chr(131) . 'L', chr(93) => chr(131) . 'M', chr(94) => chr(131) . 'N', chr(95) => chr(131) . 'O',
481
+			chr(96) => chr(131) . 'W', chr(97) => chr(130) . 'A', chr(98) => chr(130) . 'B', chr(99) => chr(130) . 'C',
482
+			chr(100) => chr(130) . 'D', chr(101) => chr(130) . 'E', chr(102) => chr(130) . 'F', chr(103) => chr(130) . 'G',
483
+			chr(104) => chr(130) . 'H', chr(105) => chr(130) . 'I', chr(106) => chr(130) . 'J', chr(107) => chr(130) . 'K',
484
+			chr(108) => chr(130) . 'L', chr(109) => chr(130) . 'M', chr(110) => chr(130) . 'N', chr(111) => chr(130) . 'O',
485
+			chr(112) => chr(130) . 'P', chr(113) => chr(130) . 'Q', chr(114) => chr(130) . 'R', chr(115) => chr(130) . 'S',
486
+			chr(116) => chr(130) . 'T', chr(117) => chr(130) . 'U', chr(118) => chr(130) . 'V', chr(119) => chr(130) . 'W',
487
+			chr(120) => chr(130) . 'X', chr(121) => chr(130) . 'Y', chr(122) => chr(130) . 'Z', chr(123) => chr(131) . 'P',
488
+			chr(124) => chr(131) . 'Q', chr(125) => chr(131) . 'R', chr(126) => chr(131) . 'S', chr(127) => chr(131) . 'T');
489 489
 		$code_ext = '';
490 490
 		$clen = strlen($code);
491
-		for ($i = 0 ; $i < $clen; ++$i) {
491
+		for ($i = 0; $i < $clen; ++$i) {
492 492
 			if (ord($code{$i}) > 127) {
493 493
 				return false;
494 494
 			}
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
 		// checksum
498 498
 		$code .= $this->checksum_code93($code);
499 499
 		// add start and stop codes
500
-		$code = '*'.$code.'*';
500
+		$code = '*' . $code . '*';
501 501
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
502 502
 		$k = 0;
503 503
 		$clen = strlen($code);
504 504
 		for ($i = 0; $i < $clen; ++$i) {
505 505
 			$char = $code{$i};
506
-			if(!isset($chr[$char])) {
506
+			if (!isset($chr[$char])) {
507 507
 				// invalid character
508 508
 				return false;
509 509
 			}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 			'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
539 539
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
540 540
 		// translate special characters
541
-		$code = strtr($code, chr(128).chr(129).chr(130).chr(131), '$/+%');	
541
+		$code = strtr($code, chr(128) . chr(129) . chr(130) . chr(131), '$/+%');	
542 542
 		$len = strlen($code);
543 543
 		// calculate check digit C
544 544
 		$p = 1;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		}
568 568
 		$check %= 47;
569 569
 		$k = $chars[$check];
570
-		return $c.$k;
570
+		return $c . $k;
571 571
 	}
572 572
 	
573 573
 	/**
@@ -579,15 +579,15 @@  discard block
 block discarded – undo
579 579
 	protected function checksum_s25($code) {
580 580
 		$len = strlen($code);
581 581
 		$sum = 0;
582
-		for ($i = 0; $i < $len; $i+=2) {
582
+		for ($i = 0; $i < $len; $i += 2) {
583 583
 			$sum += $code{$i};
584 584
 		}
585 585
 		$sum *= 3;
586
-		for ($i = 1; $i < $len; $i+=2) {
586
+		for ($i = 1; $i < $len; $i += 2) {
587 587
 			$sum += ($code{$i});
588 588
 		}
589 589
 		$r = $sum % 10;
590
-		if($r > 0) {
590
+		if ($r > 0) {
591 591
 			$r = (10 - $r);
592 592
 		}
593 593
 		return $r;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 * @return array barcode representation.
603 603
 	 * @access protected
604 604
 	 */
605
-	protected function barcode_msi($code, $checksum=false) {
605
+	protected function barcode_msi($code, $checksum = false) {
606 606
 		$chr['0'] = '100100100100';
607 607
 		$chr['1'] = '100100100110';
608 608
 		$chr['2'] = '100100110100';
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	 * @return array barcode representation.
662 662
 	 * @access protected
663 663
 	 */
664
-	protected function barcode_s25($code, $checksum=false) {
664
+	protected function barcode_s25($code, $checksum = false) {
665 665
 		$chr['0'] = '10101110111010';
666 666
 		$chr['1'] = '11101010101110';
667 667
 		$chr['2'] = '10111010101110';
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
 			// add checksum
677 677
 			$code .= $this->checksum_s25($code);
678 678
 		}
679
-		if((strlen($code) % 2) != 0) {
679
+		if ((strlen($code) % 2) != 0) {
680 680
 			// add leading zero if code-length is odd
681
-			$code = '0'.$code;
681
+			$code = '0' . $code;
682 682
 		}
683 683
 		$seq = '11011010';
684 684
 		$clen = strlen($code);
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 		$k = 0;
709 709
 		for ($i = 0; $i < $len; ++$i) {
710 710
 			$w += 1;
711
-			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
711
+			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i + 1)}))) {
712 712
 				if ($seq{$i} == '1') {
713 713
 					$t = true; // bar
714 714
 				} else {
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 * @return array barcode representation.
733 733
 	 * @access protected
734 734
 	 */
735
-	protected function barcode_i25($code, $checksum=false) {
735
+	protected function barcode_i25($code, $checksum = false) {
736 736
 		$chr['0'] = '11221';
737 737
 		$chr['1'] = '21112';
738 738
 		$chr['2'] = '12112';
@@ -749,27 +749,27 @@  discard block
 block discarded – undo
749 749
 			// add checksum
750 750
 			$code .= $this->checksum_s25($code);
751 751
 		}
752
-		if((strlen($code) % 2) != 0) {
752
+		if ((strlen($code) % 2) != 0) {
753 753
 			// add leading zero if code-length is odd
754
-			$code = '0'.$code;
754
+			$code = '0' . $code;
755 755
 		}
756 756
 		// add start and stop codes
757
-		$code = 'AA'.strtolower($code).'ZA';
757
+		$code = 'AA' . strtolower($code) . 'ZA';
758 758
 			
759 759
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
760 760
 		$k = 0;
761 761
 		$clen = strlen($code);
762 762
 		for ($i = 0; $i < $clen; $i = ($i + 2)) {
763 763
 			$char_bar = $code{$i};
764
-			$char_space = $code{$i+1};
765
-			if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
764
+			$char_space = $code{$i + 1};
765
+			if ((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
766 766
 				// invalid character
767 767
 				return false;
768 768
 			}
769 769
 			// create a bar-space sequence
770 770
 			$seq = '';
771 771
 			$chrlen = strlen($chr[$char_bar]);
772
-			for ($s = 0; $s < $chrlen; $s++){
772
+			for ($s = 0; $s < $chrlen; $s++) {
773 773
 				$seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
774 774
 			}
775 775
 			$seqlen = strlen($seq);
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	 * @return array barcode representation.
797 797
 	 * @access protected
798 798
 	 */
799
-	protected function barcode_c128($code, $type='B') {
799
+	protected function barcode_c128($code, $type = 'B') {
800 800
 		$chr = array(
801 801
 			'212222', /* 00 */
802 802
 			'222122', /* 01 */
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 			'200000'  /* END */
909 909
 		);
910 910
 		$keys = '';
911
-		switch(strtoupper($type)) {
911
+		switch (strtoupper($type)) {
912 912
 			case 'A': {
913 913
 				$startid = 103;
914 914
 				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			}
920 920
 			case 'B': {
921 921
 				$startid = 104;
922
-				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
922
+				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127);
923 923
 				break;
924 924
 			}
925 925
 			case 'C': {
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 				$new_code = '';
936 936
 				$hclen = (strlen($code) / 2);
937 937
 				for ($i = 0; $i < $hclen; ++$i) {
938
-					$new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)}));
938
+					$new_code .= chr(intval($code{(2 * $i)} . $code{(2 * $i + 1)}));
939 939
 				}
940 940
 				$code = $new_code;
941 941
 				break;
@@ -948,20 +948,20 @@  discard block
 block discarded – undo
948 948
 		$sum = $startid;
949 949
 		$clen = strlen($code);
950 950
 		for ($i = 0; $i < $clen; ++$i) {
951
-			$sum +=  (strpos($keys, $code{$i}) * ($i+1));
951
+			$sum += (strpos($keys, $code{$i}) * ($i + 1));
952 952
 		}
953 953
 		$check = ($sum % 103);
954 954
 		// add start, check and stop codes
955
-		$code = chr($startid).$code.chr($check).chr(106).chr(107);
955
+		$code = chr($startid) . $code . chr($check) . chr(106) . chr(107);
956 956
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
957 957
 		$k = 0;
958 958
 		$len = strlen($code);
959 959
 		for ($i = 0; $i < $len; ++$i) {
960 960
 			$ck = strpos($keys, $code{$i});
961
-			if (($i == 0) OR ($i > ($len-4))) {
961
+			if (($i == 0) OR ($i > ($len - 4))) {
962 962
 				$char_num = ord($code{$i});
963 963
 				$seq = $chr[$char_num];
964
-			} elseif(($ck >= 0) AND isset($chr[$ck])) {
964
+			} elseif (($ck >= 0) AND isset($chr[$ck])) {
965 965
 					$seq = $chr[$ck];
966 966
 			} else {
967 967
 				// invalid character
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	 * @return array barcode representation.
993 993
 	 * @access protected
994 994
 	 */
995
-	protected function barcode_eanupc($code, $len=13) {
995
+	protected function barcode_eanupc($code, $len = 13) {
996 996
 		$upce = false;
997 997
 		if ($len == 6) {
998 998
 			$len = 12; // UPC-A
@@ -1004,21 +1004,21 @@  discard block
 block discarded – undo
1004 1004
 		$code_len = strlen($code);
1005 1005
 		// calculate check digit
1006 1006
 		$sum_a = 0;
1007
-		for ($i = 1; $i < $data_len; $i+=2) {
1007
+		for ($i = 1; $i < $data_len; $i += 2) {
1008 1008
 			$sum_a += $code{$i};
1009 1009
 		}
1010 1010
 		if ($len > 12) {
1011 1011
 			$sum_a *= 3;
1012 1012
 		}
1013 1013
 		$sum_b = 0;
1014
-		for ($i = 0; $i < $data_len; $i+=2) {
1014
+		for ($i = 0; $i < $data_len; $i += 2) {
1015 1015
 			$sum_b += ($code{$i});
1016 1016
 		}
1017 1017
 		if ($len < 13) {
1018 1018
 			$sum_b *= 3;
1019 1019
 		}
1020 1020
 		$r = ($sum_a + $sum_b) % 10;
1021
-		if($r > 0) {
1021
+		if ($r > 0) {
1022 1022
 			$r = (10 - $r);
1023 1023
 		}
1024 1024
 		if ($code_len == $data_len) {
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 		}
1031 1031
 		if ($len == 12) {
1032 1032
 			// UPC-A
1033
-			$code = '0'.$code;
1033
+			$code = '0' . $code;
1034 1034
 			++$len;
1035 1035
 		}
1036 1036
 		if ($upce) {
@@ -1038,20 +1038,20 @@  discard block
 block discarded – undo
1038 1038
 			$tmp = substr($code, 4, 3);
1039 1039
 			if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
1040 1040
 				// manufacturer code ends in 000, 100, or 200
1041
-				$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
1041
+				$upce_code = substr($code, 2, 2) . substr($code, 9, 3) . substr($code, 4, 1);
1042 1042
 			} else {
1043 1043
 				$tmp = substr($code, 5, 2);
1044 1044
 				if ($tmp == '00') {
1045 1045
 					// manufacturer code ends in 00
1046
-					$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
1046
+					$upce_code = substr($code, 2, 3) . substr($code, 10, 2) . '3';
1047 1047
 				} else {
1048 1048
 					$tmp = substr($code, 6, 1);
1049 1049
 					if ($tmp == '0') {
1050 1050
 						// manufacturer code ends in 0
1051
-						$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
1051
+						$upce_code = substr($code, 2, 4) . substr($code, 11, 1) . '4';
1052 1052
 					} else {
1053 1053
 						// manufacturer code does not end in zero
1054
-						$upce_code = substr($code, 2, 5).substr($code, 11, 1);
1054
+						$upce_code = substr($code, 2, 5) . substr($code, 11, 1);
1055 1055
 					}
1056 1056
 				}
1057 1057
 			}
@@ -1093,41 +1093,41 @@  discard block
 block discarded – undo
1093 1093
 				'9'=>'1110100')
1094 1094
 		);
1095 1095
 		$parities = array(
1096
-			'0'=>array('A','A','A','A','A','A'),
1097
-			'1'=>array('A','A','B','A','B','B'),
1098
-			'2'=>array('A','A','B','B','A','B'),
1099
-			'3'=>array('A','A','B','B','B','A'),
1100
-			'4'=>array('A','B','A','A','B','B'),
1101
-			'5'=>array('A','B','B','A','A','B'),
1102
-			'6'=>array('A','B','B','B','A','A'),
1103
-			'7'=>array('A','B','A','B','A','B'),
1104
-			'8'=>array('A','B','A','B','B','A'),
1105
-			'9'=>array('A','B','B','A','B','A')
1096
+			'0'=>array('A', 'A', 'A', 'A', 'A', 'A'),
1097
+			'1'=>array('A', 'A', 'B', 'A', 'B', 'B'),
1098
+			'2'=>array('A', 'A', 'B', 'B', 'A', 'B'),
1099
+			'3'=>array('A', 'A', 'B', 'B', 'B', 'A'),
1100
+			'4'=>array('A', 'B', 'A', 'A', 'B', 'B'),
1101
+			'5'=>array('A', 'B', 'B', 'A', 'A', 'B'),
1102
+			'6'=>array('A', 'B', 'B', 'B', 'A', 'A'),
1103
+			'7'=>array('A', 'B', 'A', 'B', 'A', 'B'),
1104
+			'8'=>array('A', 'B', 'A', 'B', 'B', 'A'),
1105
+			'9'=>array('A', 'B', 'B', 'A', 'B', 'A')
1106 1106
 		);
1107 1107
 		$upce_parities = array();
1108 1108
 		$upce_parities[0] = array(
1109
-			'0'=>array('B','B','B','A','A','A'),
1110
-			'1'=>array('B','B','A','B','A','A'),
1111
-			'2'=>array('B','B','A','A','B','A'),
1112
-			'3'=>array('B','B','A','A','A','B'),
1113
-			'4'=>array('B','A','B','B','A','A'),
1114
-			'5'=>array('B','A','A','B','B','A'),
1115
-			'6'=>array('B','A','A','A','B','B'),
1116
-			'7'=>array('B','A','B','A','B','A'),
1117
-			'8'=>array('B','A','B','A','A','B'),
1118
-			'9'=>array('B','A','A','B','A','B')
1109
+			'0'=>array('B', 'B', 'B', 'A', 'A', 'A'),
1110
+			'1'=>array('B', 'B', 'A', 'B', 'A', 'A'),
1111
+			'2'=>array('B', 'B', 'A', 'A', 'B', 'A'),
1112
+			'3'=>array('B', 'B', 'A', 'A', 'A', 'B'),
1113
+			'4'=>array('B', 'A', 'B', 'B', 'A', 'A'),
1114
+			'5'=>array('B', 'A', 'A', 'B', 'B', 'A'),
1115
+			'6'=>array('B', 'A', 'A', 'A', 'B', 'B'),
1116
+			'7'=>array('B', 'A', 'B', 'A', 'B', 'A'),
1117
+			'8'=>array('B', 'A', 'B', 'A', 'A', 'B'),
1118
+			'9'=>array('B', 'A', 'A', 'B', 'A', 'B')
1119 1119
 		);
1120 1120
 		$upce_parities[1] = array(
1121
-			'0'=>array('A','A','A','B','B','B'),
1122
-			'1'=>array('A','A','B','A','B','B'),
1123
-			'2'=>array('A','A','B','B','A','B'),
1124
-			'3'=>array('A','A','B','B','B','A'),
1125
-			'4'=>array('A','B','A','A','B','B'),
1126
-			'5'=>array('A','B','B','A','A','B'),
1127
-			'6'=>array('A','B','B','B','A','A'),
1128
-			'7'=>array('A','B','A','B','A','B'),
1129
-			'8'=>array('A','B','A','B','B','A'),
1130
-			'9'=>array('A','B','B','A','B','A')
1121
+			'0'=>array('A', 'A', 'A', 'B', 'B', 'B'),
1122
+			'1'=>array('A', 'A', 'B', 'A', 'B', 'B'),
1123
+			'2'=>array('A', 'A', 'B', 'B', 'A', 'B'),
1124
+			'3'=>array('A', 'A', 'B', 'B', 'B', 'A'),
1125
+			'4'=>array('A', 'B', 'A', 'A', 'B', 'B'),
1126
+			'5'=>array('A', 'B', 'B', 'A', 'A', 'B'),
1127
+			'6'=>array('A', 'B', 'B', 'B', 'A', 'A'),
1128
+			'7'=>array('A', 'B', 'A', 'B', 'A', 'B'),
1129
+			'8'=>array('A', 'B', 'A', 'B', 'B', 'A'),
1130
+			'9'=>array('A', 'B', 'B', 'A', 'B', 'A')
1131 1131
 		);
1132 1132
 		$k = 0;
1133 1133
 		$seq = '101'; // left guard bar
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			} else {
1149 1149
 				$p = $parities[$code{0}];
1150 1150
 				for ($i = 1; $i < $half_len; ++$i) {
1151
-					$seq .= $codes[$p[$i-1]][$code{$i}];
1151
+					$seq .= $codes[$p[$i - 1]][$code{$i}];
1152 1152
 				}
1153 1153
 			}
1154 1154
 			$seq .= '01010'; // center guard bar
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 		$w = 0;
1162 1162
 		for ($i = 0; $i < $clen; ++$i) {
1163 1163
 			$w += 1;
1164
-			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
1164
+			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i + 1)}))) {
1165 1165
 				if ($seq{$i} == '1') {
1166 1166
 					$t = true; // bar
1167 1167
 				} else {
@@ -1185,14 +1185,14 @@  discard block
 block discarded – undo
1185 1185
 	 * @return array barcode representation.
1186 1186
 	 * @access protected
1187 1187
 	 */
1188
-	protected function barcode_eanext($code, $len=5) {
1188
+	protected function barcode_eanext($code, $len = 5) {
1189 1189
 		//Padding
1190 1190
 		$code = str_pad($code, $len, '0', STR_PAD_LEFT);
1191 1191
 		// calculate check digit
1192 1192
 		if ($len == 2) {
1193 1193
 			$r = $code % 4;
1194 1194
 		} elseif ($len == 5) {
1195
-			$r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3}));
1195
+			$r = (3 * ($code{0} +$code{2} +$code{4})) + (9 * ($code{1} +$code{3}));
1196 1196
 			$r %= 10;
1197 1197
 		} else {
1198 1198
 			return false;
@@ -1224,22 +1224,22 @@  discard block
 block discarded – undo
1224 1224
 		);
1225 1225
 		$parities = array();
1226 1226
 		$parities[2] = array(
1227
-			'0'=>array('A','A'),
1228
-			'1'=>array('A','B'),
1229
-			'2'=>array('B','A'),
1230
-			'3'=>array('B','B')
1227
+			'0'=>array('A', 'A'),
1228
+			'1'=>array('A', 'B'),
1229
+			'2'=>array('B', 'A'),
1230
+			'3'=>array('B', 'B')
1231 1231
 		);
1232 1232
 		$parities[5] = array(
1233
-			'0'=>array('B','B','A','A','A'),
1234
-			'1'=>array('B','A','B','A','A'),
1235
-			'2'=>array('B','A','A','B','A'),
1236
-			'3'=>array('B','A','A','A','B'),
1237
-			'4'=>array('A','B','B','A','A'),
1238
-			'5'=>array('A','A','B','B','A'),
1239
-			'6'=>array('A','A','A','B','B'),
1240
-			'7'=>array('A','B','A','B','A'),
1241
-			'8'=>array('A','B','A','A','B'),
1242
-			'9'=>array('A','A','B','A','B')
1233
+			'0'=>array('B', 'B', 'A', 'A', 'A'),
1234
+			'1'=>array('B', 'A', 'B', 'A', 'A'),
1235
+			'2'=>array('B', 'A', 'A', 'B', 'A'),
1236
+			'3'=>array('B', 'A', 'A', 'A', 'B'),
1237
+			'4'=>array('A', 'B', 'B', 'A', 'A'),
1238
+			'5'=>array('A', 'A', 'B', 'B', 'A'),
1239
+			'6'=>array('A', 'A', 'A', 'B', 'B'),
1240
+			'7'=>array('A', 'B', 'A', 'B', 'A'),
1241
+			'8'=>array('A', 'B', 'A', 'A', 'B'),
1242
+			'9'=>array('A', 'A', 'B', 'A', 'B')
1243 1243
 		);	
1244 1244
 		$p = $parities[$len][$r];
1245 1245
 		$seq = '1011'; // left guard bar
@@ -1260,33 +1260,33 @@  discard block
 block discarded – undo
1260 1260
 	 * @return array barcode representation.
1261 1261
 	 * @access protected
1262 1262
 	 */
1263
-	protected function barcode_postnet($code, $planet=false) {
1263
+	protected function barcode_postnet($code, $planet = false) {
1264 1264
 		// bar lenght
1265 1265
 		if ($planet) {
1266 1266
 			$barlen = Array(
1267
-				0 => Array(1,1,2,2,2),
1268
-				1 => Array(2,2,2,1,1),
1269
-				2 => Array(2,2,1,2,1),
1270
-				3 => Array(2,2,1,1,2),
1271
-				4 => Array(2,1,2,2,1),
1272
-				5 => Array(2,1,2,1,2),
1273
-				6 => Array(2,1,1,2,2),
1274
-				7 => Array(1,2,2,2,1),
1275
-				8 => Array(1,2,2,1,2),
1276
-				9 => Array(1,2,1,2,2)
1267
+				0 => Array(1, 1, 2, 2, 2),
1268
+				1 => Array(2, 2, 2, 1, 1),
1269
+				2 => Array(2, 2, 1, 2, 1),
1270
+				3 => Array(2, 2, 1, 1, 2),
1271
+				4 => Array(2, 1, 2, 2, 1),
1272
+				5 => Array(2, 1, 2, 1, 2),
1273
+				6 => Array(2, 1, 1, 2, 2),
1274
+				7 => Array(1, 2, 2, 2, 1),
1275
+				8 => Array(1, 2, 2, 1, 2),
1276
+				9 => Array(1, 2, 1, 2, 2)
1277 1277
 			);
1278 1278
 		} else {
1279 1279
 			$barlen = Array(
1280
-				0 => Array(2,2,1,1,1),
1281
-				1 => Array(1,1,1,2,2),
1282
-				2 => Array(1,1,2,1,2),
1283
-				3 => Array(1,1,2,2,1),
1284
-				4 => Array(1,2,1,1,2),
1285
-				5 => Array(1,2,1,2,1),
1286
-				6 => Array(1,2,2,1,1),
1287
-				7 => Array(2,1,1,1,2),
1288
-				8 => Array(2,1,1,2,1),
1289
-				9 => Array(2,1,2,1,1)
1280
+				0 => Array(2, 2, 1, 1, 1),
1281
+				1 => Array(1, 1, 1, 2, 2),
1282
+				2 => Array(1, 1, 2, 1, 2),
1283
+				3 => Array(1, 1, 2, 2, 1),
1284
+				4 => Array(1, 2, 1, 1, 2),
1285
+				5 => Array(1, 2, 1, 2, 1),
1286
+				6 => Array(1, 2, 2, 1, 1),
1287
+				7 => Array(2, 1, 1, 1, 2),
1288
+				8 => Array(2, 1, 1, 2, 1),
1289
+				9 => Array(2, 1, 2, 1, 1)
1290 1290
 			);
1291 1291
 		}
1292 1292
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 			$sum += intval($code{$i});
1301 1301
 		}
1302 1302
 		$chkd = ($sum % 10);
1303
-		if($chkd > 0) {
1303
+		if ($chkd > 0) {
1304 1304
 			$chkd = (10 - $chkd);
1305 1305
 		}
1306 1306
 		$code .= $chkd;
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 	 * @return array barcode representation.
1334 1334
 	 * @access protected
1335 1335
 	 */
1336
-	protected function barcode_rms4cc($code, $kix=false) {
1336
+	protected function barcode_rms4cc($code, $kix = false) {
1337 1337
 		$notkix = !$kix;
1338 1338
 		// bar mode
1339 1339
 		// 1 = pos 1, length 2
@@ -1341,42 +1341,42 @@  discard block
 block discarded – undo
1341 1341
 		// 3 = pos 2, length 1
1342 1342
 		// 4 = pos 2, length 2
1343 1343
 		$barmode = array(
1344
-			'0' => array(3,3,2,2),
1345
-			'1' => array(3,4,1,2),
1346
-			'2' => array(3,4,2,1),
1347
-			'3' => array(4,3,1,2),
1348
-			'4' => array(4,3,2,1),
1349
-			'5' => array(4,4,1,1),
1350
-			'6' => array(3,1,4,2),
1351
-			'7' => array(3,2,3,2),
1352
-			'8' => array(3,2,4,1),
1353
-			'9' => array(4,1,3,2),
1354
-			'A' => array(4,1,4,1),
1355
-			'B' => array(4,2,3,1),
1356
-			'C' => array(3,1,2,4),
1357
-			'D' => array(3,2,1,4),
1358
-			'E' => array(3,2,2,3),
1359
-			'F' => array(4,1,1,4),
1360
-			'G' => array(4,1,2,3),
1361
-			'H' => array(4,2,1,3),
1362
-			'I' => array(1,3,4,2),
1363
-			'J' => array(1,4,3,2),
1364
-			'K' => array(1,4,4,1),
1365
-			'L' => array(2,3,3,2),
1366
-			'M' => array(2,3,4,1),
1367
-			'N' => array(2,4,3,1),
1368
-			'O' => array(1,3,2,4),
1369
-			'P' => array(1,4,1,4),
1370
-			'Q' => array(1,4,2,3),
1371
-			'R' => array(2,3,1,4),
1372
-			'S' => array(2,3,2,3),
1373
-			'T' => array(2,4,1,3),
1374
-			'U' => array(1,1,4,4),
1375
-			'V' => array(1,2,3,4),
1376
-			'W' => array(1,2,4,3),
1377
-			'X' => array(2,1,3,4),
1378
-			'Y' => array(2,1,4,3),
1379
-			'Z' => array(2,2,3,3)		
1344
+			'0' => array(3, 3, 2, 2),
1345
+			'1' => array(3, 4, 1, 2),
1346
+			'2' => array(3, 4, 2, 1),
1347
+			'3' => array(4, 3, 1, 2),
1348
+			'4' => array(4, 3, 2, 1),
1349
+			'5' => array(4, 4, 1, 1),
1350
+			'6' => array(3, 1, 4, 2),
1351
+			'7' => array(3, 2, 3, 2),
1352
+			'8' => array(3, 2, 4, 1),
1353
+			'9' => array(4, 1, 3, 2),
1354
+			'A' => array(4, 1, 4, 1),
1355
+			'B' => array(4, 2, 3, 1),
1356
+			'C' => array(3, 1, 2, 4),
1357
+			'D' => array(3, 2, 1, 4),
1358
+			'E' => array(3, 2, 2, 3),
1359
+			'F' => array(4, 1, 1, 4),
1360
+			'G' => array(4, 1, 2, 3),
1361
+			'H' => array(4, 2, 1, 3),
1362
+			'I' => array(1, 3, 4, 2),
1363
+			'J' => array(1, 4, 3, 2),
1364
+			'K' => array(1, 4, 4, 1),
1365
+			'L' => array(2, 3, 3, 2),
1366
+			'M' => array(2, 3, 4, 1),
1367
+			'N' => array(2, 4, 3, 1),
1368
+			'O' => array(1, 3, 2, 4),
1369
+			'P' => array(1, 4, 1, 4),
1370
+			'Q' => array(1, 4, 2, 3),
1371
+			'R' => array(2, 3, 1, 4),
1372
+			'S' => array(2, 3, 2, 3),
1373
+			'T' => array(2, 4, 1, 3),
1374
+			'U' => array(1, 1, 4, 4),
1375
+			'V' => array(1, 2, 3, 4),
1376
+			'W' => array(1, 2, 4, 3),
1377
+			'X' => array(2, 1, 3, 4),
1378
+			'Y' => array(2, 1, 4, 3),
1379
+			'Z' => array(2, 2, 3, 3)		
1380 1380
 		);
1381 1381
 		$code = strtoupper($code);
1382 1382
 		$len = strlen($code);
@@ -1384,42 +1384,42 @@  discard block
 block discarded – undo
1384 1384
 		if ($notkix) {
1385 1385
 			// table for checksum calculation (row,col)
1386 1386
 			$checktable = array(
1387
-				'0' => array(1,1),
1388
-				'1' => array(1,2),
1389
-				'2' => array(1,3),
1390
-				'3' => array(1,4),
1391
-				'4' => array(1,5),
1392
-				'5' => array(1,0),
1393
-				'6' => array(2,1),
1394
-				'7' => array(2,2),
1395
-				'8' => array(2,3),
1396
-				'9' => array(2,4),
1397
-				'A' => array(2,5),
1398
-				'B' => array(2,0),
1399
-				'C' => array(3,1),
1400
-				'D' => array(3,2),
1401
-				'E' => array(3,3),
1402
-				'F' => array(3,4),
1403
-				'G' => array(3,5),
1404
-				'H' => array(3,0),
1405
-				'I' => array(4,1),
1406
-				'J' => array(4,2),
1407
-				'K' => array(4,3),
1408
-				'L' => array(4,4),
1409
-				'M' => array(4,5),
1410
-				'N' => array(4,0),
1411
-				'O' => array(5,1),
1412
-				'P' => array(5,2),
1413
-				'Q' => array(5,3),
1414
-				'R' => array(5,4),
1415
-				'S' => array(5,5),
1416
-				'T' => array(5,0),
1417
-				'U' => array(0,1),
1418
-				'V' => array(0,2),
1419
-				'W' => array(0,3),
1420
-				'X' => array(0,4),
1421
-				'Y' => array(0,5),
1422
-				'Z' => array(0,0)
1387
+				'0' => array(1, 1),
1388
+				'1' => array(1, 2),
1389
+				'2' => array(1, 3),
1390
+				'3' => array(1, 4),
1391
+				'4' => array(1, 5),
1392
+				'5' => array(1, 0),
1393
+				'6' => array(2, 1),
1394
+				'7' => array(2, 2),
1395
+				'8' => array(2, 3),
1396
+				'9' => array(2, 4),
1397
+				'A' => array(2, 5),
1398
+				'B' => array(2, 0),
1399
+				'C' => array(3, 1),
1400
+				'D' => array(3, 2),
1401
+				'E' => array(3, 3),
1402
+				'F' => array(3, 4),
1403
+				'G' => array(3, 5),
1404
+				'H' => array(3, 0),
1405
+				'I' => array(4, 1),
1406
+				'J' => array(4, 2),
1407
+				'K' => array(4, 3),
1408
+				'L' => array(4, 4),
1409
+				'M' => array(4, 5),
1410
+				'N' => array(4, 0),
1411
+				'O' => array(5, 1),
1412
+				'P' => array(5, 2),
1413
+				'Q' => array(5, 3),
1414
+				'R' => array(5, 4),
1415
+				'S' => array(5, 5),
1416
+				'T' => array(5, 0),
1417
+				'U' => array(0, 1),
1418
+				'V' => array(0, 2),
1419
+				'W' => array(0, 3),
1420
+				'X' => array(0, 4),
1421
+				'Y' => array(0, 5),
1422
+				'Z' => array(0, 0)
1423 1423
 			);
1424 1424
 			$row = 0;
1425 1425
 			$col = 0;
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 			}
1430 1430
 			$row %= 6;
1431 1431
 			$col %= 6;
1432
-			$chk = array_keys($checktable, array($row,$col));
1432
+			$chk = array_keys($checktable, array($row, $col));
1433 1433
 			$code .= $chk[0];
1434 1434
 			++$len;
1435 1435
 		}
@@ -1511,7 +1511,7 @@  discard block
 block discarded – undo
1511 1511
 		$k = 0;
1512 1512
 		$w = 0;
1513 1513
 		$seq = '';
1514
-		$code = 'A'.strtoupper($code).'A';
1514
+		$code = 'A' . strtoupper($code) . 'A';
1515 1515
 		$len = strlen($code);
1516 1516
 		for ($i = 0; $i < $len; ++$i) {
1517 1517
 			if (!isset($chr[$code{$i}])) {
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 			$code .= $check;
1604 1604
 			++$len;
1605 1605
 		}
1606
-		$code = 'S'.$code.'S';
1606
+		$code = 'S' . $code . 'S';
1607 1607
 		$len += 3;
1608 1608
 		for ($i = 0; $i < $len; ++$i) {
1609 1609
 			if (!isset($chr[$code{$i}])) {
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 					break;
1680 1680
 				}
1681 1681
 			}
1682
-		} while($code != 0);
1682
+		} while ($code != 0);
1683 1683
 		$seq = strrev($seq);
1684 1684
 		$k = 0;
1685 1685
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
@@ -1722,10 +1722,10 @@  discard block
 block discarded – undo
1722 1722
 	 * @access protected
1723 1723
 	 */
1724 1724
 	protected function barcode_imb($code) {
1725
-		$asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8);
1726
-		$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
1727
-		$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
1728
-		$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
1725
+		$asc_chr = array(4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8);
1726
+		$dsc_chr = array(7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3);
1727
+		$asc_pos = array(3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2);
1728
+		$dsc_pos = array(2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10);
1729 1729
 		$code_arr = explode('-', $code);
1730 1730
 		$tracking_number = $code_arr[0];
1731 1731
 		if (isset($code_arr[1])) {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		$fcs = $this->imb_crc11fcs($binary_code_arr);
1774 1774
 		// exclude first 2 bits from first byte
1775 1775
 		$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
1776
-		$binary_code_102bit = $first_byte.substr($binary_code, 2);
1776
+		$binary_code_102bit = $first_byte . substr($binary_code, 2);
1777 1777
 		// convert binary data to codewords
1778 1778
 		$codewords = array();
1779 1779
 		$data = $this->hex_to_dec($binary_code_102bit);
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 		// convert codewords to characters
1794 1794
 		$characters = array();
1795 1795
 		$bitmask = 512;
1796
-		foreach($codewords as $k => $val) {
1796
+		foreach ($codewords as $k => $val) {
1797 1797
 			if ($val <= 1286) {
1798 1798
 				$chrcode = $table5of13[$val];
1799 1799
 			} else {
@@ -1848,11 +1848,11 @@  discard block
 block discarded – undo
1848 1848
 	public function dec_to_hex($number) {
1849 1849
 		$i = 0;
1850 1850
 		$hex = array();
1851
-		if($number == 0) {
1851
+		if ($number == 0) {
1852 1852
 			return '00';
1853 1853
 		}
1854
-		while($number > 0) {
1855
-			if($number == 0) {
1854
+		while ($number > 0) {
1855
+			if ($number == 0) {
1856 1856
 				array_push($hex, '0');
1857 1857
 			} else {
1858 1858
 				array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 		$dec = 0;
1874 1874
 		$bitval = 1;
1875 1875
 		$len = strlen($hex);
1876
-		for($pos = ($len - 1); $pos >= 0; --$pos) {
1876
+		for ($pos = ($len - 1); $pos >= 0; --$pos) {
1877 1877
 			$dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
1878 1878
 			$bitval = bcmul($bitval, 16);
1879 1879
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_tcpdf_5.0.002/fonts/utils/makefont.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -234,6 +234,8 @@  discard block
 block discarded – undo
234 234
 
235 235
 /**
236 236
  * Read UFM file
237
+ * @param string $file
238
+ * @param string $cidtogidmap
237 239
  */
238 240
 function ReadUFM($file, &$cidtogidmap) {
239 241
 	//Prepare empty CIDToGIDMap
@@ -526,6 +528,10 @@  discard block
 block discarded – undo
526 528
 	return rtrim($s);
527 529
 }
528 530
 
531
+/**
532
+ * @param string $file
533
+ * @param string $s
534
+ */
529 535
 function SaveToFile($file, $s, $mode='t') {
530 536
 	$f = fopen($file, 'w'.$mode);
531 537
 	if(!$f) {
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : makefont.php
4 4
 // Begin       : 2004-12-31
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
  * @param string $enc Name of the encoding table to use. Omit this parameter for TrueType Unicode, OpenType Unicode and symbolic fonts like Symbol or ZapfDingBats.
56 56
  * @param array $patch Optional modification of the encoding
57 57
  */
58
-function MakeFont($fontfile, $fmfile, $embedded=true, $enc='cp1252', $patch=array()) {
58
+function MakeFont($fontfile, $fmfile, $embedded = true, $enc = 'cp1252', $patch = array()) {
59 59
 	//Generate a font definition file
60 60
 	set_magic_quotes_runtime(0);
61 61
 	ini_set('auto_detect_line_endings', '1');
62 62
 	if (!file_exists($fontfile)) {
63
-		die('Error: file not found: '.$fontfile);
63
+		die('Error: file not found: ' . $fontfile);
64 64
 	}
65 65
 	if (!file_exists($fmfile)) {
66
-		die('Error: file not found: '.$fmfile);
66
+		die('Error: file not found: ' . $fmfile);
67 67
 	}
68 68
 	$cidtogidmap = '';
69 69
 	$map = array();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		} elseif ($ffext == 'pfb') {
78 78
 			$type = 'Type1';
79 79
 		} else {
80
-			die('Error: unrecognized font file extension: '.$ffext);
80
+			die('Error: unrecognized font file extension: ' . $ffext);
81 81
 		}
82 82
 		if ($enc) {
83 83
 			$map = ReadMap($enc);
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 		if (($ffext == 'ttf') OR ($ffext == 'otf')) {
99 99
 			$type = 'TrueTypeUnicode';
100 100
 		} else {
101
-			die('Error: not a TrueType font: '.$ffext);
101
+			die('Error: not a TrueType font: ' . $ffext);
102 102
 		}
103 103
 		$fm = ReadUFM($fmfile, $cidtogidmap);
104 104
 		$dw = $fm['MissingWidth'];
105 105
 		$fd = MakeFontDescriptor($fm, false);
106 106
 	}
107 107
 	//Start generation
108
-	$s = '<?php'."\n";
109
-	$s .= '$type=\''.$type."';\n";
110
-	$s .= '$name=\''.$fm['FontName']."';\n";
111
-	$s .= '$desc='.$fd.";\n";
108
+	$s = '<?php' . "\n";
109
+	$s .= '$type=\'' . $type . "';\n";
110
+	$s .= '$name=\'' . $fm['FontName'] . "';\n";
111
+	$s .= '$desc=' . $fd . ";\n";
112 112
 	if (!isset($fm['UnderlinePosition'])) {
113 113
 		$fm['UnderlinePosition'] = -100;
114 114
 	}
115 115
 	if (!isset($fm['UnderlineThickness'])) {
116 116
 		$fm['UnderlineThickness'] = 50;
117 117
 	}
118
-	$s .= '$up='.$fm['UnderlinePosition'].";\n";
119
-	$s .= '$ut='.$fm['UnderlineThickness'].";\n";
118
+	$s .= '$up=' . $fm['UnderlinePosition'] . ";\n";
119
+	$s .= '$ut=' . $fm['UnderlineThickness'] . ";\n";
120 120
 	if ($dw <= 0) {
121 121
 		if (isset($fm['Widths'][32]) AND ($fm['Widths'][32] > 0)) {
122 122
 			// assign default space width
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
 			$dw = 600;
126 126
 		}
127 127
 	}
128
-	$s .= '$dw='.$dw.";\n";
128
+	$s .= '$dw=' . $dw . ";\n";
129 129
 	$w = MakeWidthArray($fm);
130
-	$s .= '$cw='.$w.";\n";
131
-	$s .= '$enc=\''.$enc."';\n";
132
-	$s .= '$diff=\''.$diff."';\n";
130
+	$s .= '$cw=' . $w . ";\n";
131
+	$s .= '$enc=\'' . $enc . "';\n";
132
+	$s .= '$diff=\'' . $diff . "';\n";
133 133
 	$basename = substr(basename($fmfile), 0, -4);
134 134
 	if ($embedded) {
135 135
 		//Embedded font
136 136
 		if (($type == 'TrueType') OR ($type == 'TrueTypeUnicode')) {
137 137
 			CheckTTF($fontfile);
138 138
 		}
139
-		$f = fopen($fontfile,'rb');
139
+		$f = fopen($fontfile, 'rb');
140 140
 		if (!$f) {
141
-			die('Error: Unable to open '.$fontfile);
141
+			die('Error: Unable to open ' . $fontfile);
142 142
 		}
143 143
 		$file = fread($f, filesize($fontfile));
144 144
 		fclose($f);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			$size1 = $pos + 6;
157 157
 			if ($header AND (ord($file{$size1}) == 128)) {
158 158
 				//Strip second binary header
159
-				$file = substr($file, 0, $size1).substr($file, $size1+6);
159
+				$file = substr($file, 0, $size1) . substr($file, $size1 + 6);
160 160
 			}
161 161
 			$pos = strpos($file, '00000000');
162 162
 			if (!$pos) {
@@ -167,41 +167,41 @@  discard block
 block discarded – undo
167 167
 		}
168 168
 		$basename = strtolower($basename);
169 169
 		if (function_exists('gzcompress')) {
170
-			$cmp = $basename.'.z';
170
+			$cmp = $basename . '.z';
171 171
 			SaveToFile($cmp, gzcompress($file, 9), 'b');
172
-			$s .= '$file=\''.$cmp."';\n";
173
-			print "Font file compressed (".$cmp.")\n";
172
+			$s .= '$file=\'' . $cmp . "';\n";
173
+			print "Font file compressed (" . $cmp . ")\n";
174 174
 			if (!empty($cidtogidmap)) {
175
-				$cmp = $basename.'.ctg.z';
175
+				$cmp = $basename . '.ctg.z';
176 176
 				SaveToFile($cmp, gzcompress($cidtogidmap, 9), 'b');
177
-				print "CIDToGIDMap created and compressed (".$cmp.")\n";
178
-				$s .= '$ctg=\''.$cmp."';\n";
177
+				print "CIDToGIDMap created and compressed (" . $cmp . ")\n";
178
+				$s .= '$ctg=\'' . $cmp . "';\n";
179 179
 			}
180 180
 		} else {
181
-			$s .= '$file=\''.basename($fontfile)."';\n";
181
+			$s .= '$file=\'' . basename($fontfile) . "';\n";
182 182
 			print "Notice: font file could not be compressed (zlib extension not available)\n";
183 183
 			if (!empty($cidtogidmap)) {
184
-				$cmp = $basename.'.ctg';
184
+				$cmp = $basename . '.ctg';
185 185
 				$f = fopen($cmp, 'wb');
186 186
 				fwrite($f, $cidtogidmap);
187 187
 				fclose($f);
188
-				print "CIDToGIDMap created (".$cmp.")\n";
189
-				$s .= '$ctg=\''.$cmp."';\n";
188
+				print "CIDToGIDMap created (" . $cmp . ")\n";
189
+				$s .= '$ctg=\'' . $cmp . "';\n";
190 190
 			}
191 191
 		}
192
-		if($type == 'Type1') {
193
-			$s .= '$size1='.$size1.";\n";
194
-			$s .= '$size2='.$size2.";\n";
192
+		if ($type == 'Type1') {
193
+			$s .= '$size1=' . $size1 . ";\n";
194
+			$s .= '$size2=' . $size2 . ";\n";
195 195
 		} else {
196
-			$s.='$originalsize='.filesize($fontfile).";\n";
196
+			$s .= '$originalsize=' . filesize($fontfile) . ";\n";
197 197
 		}
198 198
 	} else {
199 199
 		//Not embedded font
200
-		$s .= '$file='."'';\n";
200
+		$s .= '$file=' . "'';\n";
201 201
 	}
202 202
 	$s .= "?>";
203
-	SaveToFile($basename.'.php',$s);
204
-	print "Font definition file generated (".$basename.".php)\n";
203
+	SaveToFile($basename . '.php', $s);
204
+	print "Font definition file generated (" . $basename . ".php)\n";
205 205
 }
206 206
 
207 207
 /**
@@ -210,22 +210,22 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function ReadMap($enc) {
212 212
 	//Read a map file
213
-	$file = dirname(__FILE__).'/enc/'.strtolower($enc).'.map';
213
+	$file = dirname(__FILE__) . '/enc/' . strtolower($enc) . '.map';
214 214
 	$a = file($file);
215 215
 	if (empty($a)) {
216
-		die('Error: encoding not found: '.$enc);
216
+		die('Error: encoding not found: ' . $enc);
217 217
 	}
218 218
 	$cc2gn = array();
219 219
 	foreach ($a as $l) {
220 220
 		if ($l{0} == '!') {
221
-			$e = preg_split('/[ \\t]+/',rtrim($l));
222
-			$cc = hexdec(substr($e[0],1));
221
+			$e = preg_split('/[ \\t]+/', rtrim($l));
222
+			$cc = hexdec(substr($e[0], 1));
223 223
 			$gn = $e[2];
224 224
 			$cc2gn[$cc] = $gn;
225 225
 		}
226 226
 	}
227
-	for($i = 0; $i <= 255; $i++) {
228
-		if(!isset($cc2gn[$i])) {
227
+	for ($i = 0; $i <= 255; $i++) {
228
+		if (!isset($cc2gn[$i])) {
229 229
 			$cc2gn[$i] = '.notdef';
230 230
 		}
231 231
 	}
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 	$widths = array();
247 247
 	$fm = array();
248
-	foreach($a as $l) {
249
-		$e = explode(' ',chop($l));
250
-		if(count($e) < 2) {
248
+	foreach ($a as $l) {
249
+		$e = explode(' ', chop($l));
250
+		if (count($e) < 2) {
251 251
 			continue;
252 252
 		}
253 253
 		$code = $e[0];
254 254
 		$param = $e[1];
255
-		if($code == 'U') {
255
+		if ($code == 'U') {
256 256
 			// U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
257 257
 			//Character metrics
258 258
 			$cc = (int)$e[1];
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$w = $e[4];
262 262
 			$glyph = $e[10];
263 263
 			$widths[$cc] = $w;
264
-			if($cc == ord('X')) {
264
+			if ($cc == ord('X')) {
265 265
 				$fm['CapXHeight'] = $e[13];
266 266
 			}
267 267
 			// Set GID
@@ -270,37 +270,37 @@  discard block
 block discarded – undo
270 270
 				$cidtogidmap{(($cc * 2) + 1)} = chr($glyph & 0xFF);
271 271
 			}
272 272
 		}
273
-		if((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) {
273
+		if ((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) {
274 274
 			$fm['MissingWidth'] = $w;
275 275
 		}
276
-		} elseif($code == 'FontName') {
276
+		} elseif ($code == 'FontName') {
277 277
 			$fm['FontName'] = $param;
278
-		} elseif($code == 'Weight') {
278
+		} elseif ($code == 'Weight') {
279 279
 			$fm['Weight'] = $param;
280
-		} elseif($code == 'ItalicAngle') {
280
+		} elseif ($code == 'ItalicAngle') {
281 281
 			$fm['ItalicAngle'] = (double)$param;
282
-		} elseif($code == 'Ascender') {
282
+		} elseif ($code == 'Ascender') {
283 283
 			$fm['Ascender'] = (int)$param;
284
-		} elseif($code == 'Descender') {
284
+		} elseif ($code == 'Descender') {
285 285
 			$fm['Descender'] = (int)$param;
286
-		} elseif($code == 'UnderlineThickness') {
286
+		} elseif ($code == 'UnderlineThickness') {
287 287
 			$fm['UnderlineThickness'] = (int)$param;
288
-		} elseif($code == 'UnderlinePosition') {
288
+		} elseif ($code == 'UnderlinePosition') {
289 289
 			$fm['UnderlinePosition'] = (int)$param;
290
-		} elseif($code == 'IsFixedPitch') {
290
+		} elseif ($code == 'IsFixedPitch') {
291 291
 			$fm['IsFixedPitch'] = ($param == 'true');
292
-		} elseif($code == 'FontBBox') {
292
+		} elseif ($code == 'FontBBox') {
293 293
 			$fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
294
-		} elseif($code == 'CapHeight') {
294
+		} elseif ($code == 'CapHeight') {
295 295
 			$fm['CapHeight'] = (int)$param;
296
-		} elseif($code == 'StdVW') {
296
+		} elseif ($code == 'StdVW') {
297 297
 			$fm['StdVW'] = (int)$param;
298 298
 		}
299 299
 	}
300
-	if(!isset($fm['MissingWidth'])) {
300
+	if (!isset($fm['MissingWidth'])) {
301 301
 		$fm['MissingWidth'] = 600;
302 302
 	}
303
-	if(!isset($fm['FontName'])) {
303
+	if (!isset($fm['FontName'])) {
304 304
 		die('FontName not found');
305 305
 	}
306 306
 	$fm['Widths'] = $widths;
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 /**
311 311
  * Read AFM file
312 312
  */
313
-function ReadAFM($file,&$map) {
313
+function ReadAFM($file, &$map) {
314 314
 	//Read a font metric file
315 315
 	$a = file($file);
316
-	if(empty($a)) {
316
+	if (empty($a)) {
317 317
 		die('File not found');
318 318
 	}
319 319
 	$widths = array();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		'combiningdotbelow'=>'dotbelowcomb',
354 354
 		'dongsign'=>'dong'
355 355
 		);
356
-	foreach($a as $l) {
356
+	foreach ($a as $l) {
357 357
 		$e = explode(' ', rtrim($l));
358 358
 		if (count($e) < 2) {
359 359
 			continue;
@@ -381,34 +381,34 @@  discard block
 block discarded – undo
381 381
 				$widths[$cc] = $w;
382 382
 			} else {
383 383
 				$widths[$gn] = $w;
384
-				if($gn == 'X') {
384
+				if ($gn == 'X') {
385 385
 					$fm['CapXHeight'] = $e[13];
386 386
 				}
387 387
 			}
388
-			if($gn == '.notdef') {
388
+			if ($gn == '.notdef') {
389 389
 				$fm['MissingWidth'] = $w;
390 390
 			}
391
-		} elseif($code == 'FontName') {
391
+		} elseif ($code == 'FontName') {
392 392
 			$fm['FontName'] = $param;
393
-		} elseif($code == 'Weight') {
393
+		} elseif ($code == 'Weight') {
394 394
 			$fm['Weight'] = $param;
395
-		} elseif($code == 'ItalicAngle') {
395
+		} elseif ($code == 'ItalicAngle') {
396 396
 			$fm['ItalicAngle'] = (double)$param;
397
-		} elseif($code == 'Ascender') {
397
+		} elseif ($code == 'Ascender') {
398 398
 			$fm['Ascender'] = (int)$param;
399
-		} elseif($code == 'Descender') {
399
+		} elseif ($code == 'Descender') {
400 400
 			$fm['Descender'] = (int)$param;
401
-		} elseif($code == 'UnderlineThickness') {
401
+		} elseif ($code == 'UnderlineThickness') {
402 402
 			$fm['UnderlineThickness'] = (int)$param;
403
-		} elseif($code == 'UnderlinePosition') {
403
+		} elseif ($code == 'UnderlinePosition') {
404 404
 			$fm['UnderlinePosition'] = (int)$param;
405
-		} elseif($code == 'IsFixedPitch') {
405
+		} elseif ($code == 'IsFixedPitch') {
406 406
 			$fm['IsFixedPitch'] = ($param == 'true');
407
-		} elseif($code == 'FontBBox') {
407
+		} elseif ($code == 'FontBBox') {
408 408
 			$fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
409
-		} elseif($code == 'CapHeight') {
409
+		} elseif ($code == 'CapHeight') {
410 410
 			$fm['CapHeight'] = (int)$param;
411
-		} elseif($code == 'StdVW') {
411
+		} elseif ($code == 'StdVW') {
412 412
 			$fm['StdVW'] = (int)$param;
413 413
 		}
414 414
 	}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		//Order widths according to map
426 426
 		for ($i = 0; $i <= 255; $i++) {
427 427
 			if (!isset($widths[$map[$i]])) {
428
-				print "Warning: character ".$map[$i]." is missing\n";
428
+				print "Warning: character " . $map[$i] . " is missing\n";
429 429
 				$widths[$i] = $widths['.notdef'];
430 430
 			} else {
431 431
 				$widths[$i] = $widths[$map[$i]];
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 	return $fm;
437 437
 }
438 438
 
439
-function MakeFontDescriptor($fm, $symbolic=false) {
439
+function MakeFontDescriptor($fm, $symbolic = false) {
440 440
 	//Ascent
441 441
 	$asc = (isset($fm['Ascender']) ? $fm['Ascender'] : 1000);
442
-	$fd = "array('Ascent'=>".$asc;
442
+	$fd = "array('Ascent'=>" . $asc;
443 443
 	//Descent
444 444
 	$desc = (isset($fm['Descender']) ? $fm['Descender'] : -200);
445
-	$fd .= ",'Descent'=>".$desc;
445
+	$fd .= ",'Descent'=>" . $desc;
446 446
 	//CapHeight
447 447
 	if (isset($fm['CapHeight'])) {
448 448
 		$ch = $fm['CapHeight'];
@@ -451,31 +451,31 @@  discard block
 block discarded – undo
451 451
 	} else {
452 452
 		$ch = $asc;
453 453
 	}
454
-	$fd .= ",'CapHeight'=>".$ch;
454
+	$fd .= ",'CapHeight'=>" . $ch;
455 455
 	//Flags
456 456
 	$flags = 0;
457 457
 	if (isset($fm['IsFixedPitch']) AND $fm['IsFixedPitch']) {
458
-		$flags += 1<<0;
458
+		$flags += 1 << 0;
459 459
 	}
460 460
 	if ($symbolic) {
461
-		$flags += 1<<2;
461
+		$flags += 1 << 2;
462 462
 	} else {
463
-		$flags += 1<<5;
463
+		$flags += 1 << 5;
464 464
 	}
465 465
 	if (isset($fm['ItalicAngle']) AND ($fm['ItalicAngle'] != 0)) {
466
-		$flags += 1<<6;
466
+		$flags += 1 << 6;
467 467
 	}
468
-	$fd .= ",'Flags'=>".$flags;
468
+	$fd .= ",'Flags'=>" . $flags;
469 469
 	//FontBBox
470 470
 	if (isset($fm['FontBBox'])) {
471 471
 		$fbb = $fm['FontBBox'];
472 472
 	} else {
473 473
 		$fbb = array(0, ($desc - 100), 1000, ($asc + 100));
474 474
 	}
475
-	$fd .= ",'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'";
475
+	$fd .= ",'FontBBox'=>'[" . $fbb[0] . ' ' . $fbb[1] . ' ' . $fbb[2] . ' ' . $fbb[3] . "]'";
476 476
 	//ItalicAngle
477 477
 	$ia = (isset($fm['ItalicAngle']) ? $fm['ItalicAngle'] : 0);
478
-	$fd .= ",'ItalicAngle'=>".$ia;
478
+	$fd .= ",'ItalicAngle'=>" . $ia;
479 479
 	//StemV
480 480
 	if (isset($fm['StdVW'])) {
481 481
 		$stemv = $fm['StdVW'];
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 	} else {
485 485
 		$stemv = 70;
486 486
 	}
487
-	$fd .= ",'StemV'=>".$stemv;
487
+	$fd .= ",'StemV'=>" . $stemv;
488 488
 	//MissingWidth
489
-	if(isset($fm['MissingWidth'])) {
490
-		$fd .= ",'MissingWidth'=>".$fm['MissingWidth'];
489
+	if (isset($fm['MissingWidth'])) {
490
+		$fd .= ",'MissingWidth'=>" . $fm['MissingWidth'];
491 491
 	}
492 492
 	$fd .= ')';
493 493
 	return $fd;
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	$c = 0;
502 502
 	foreach ($cw as $i => $w) {
503 503
 		if (is_numeric($i)) {
504
-			$els[] = (((($c++)%10) == 0) ? "\n" : '').$i.'=>'.$w;
504
+			$els[] = (((($c++) % 10) == 0) ? "\n" : '') . $i . '=>' . $w;
505 505
 		}
506 506
 	}
507 507
 	$s .= implode(',', $els);
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
 	$last = 0;
517 517
 	for ($i = 32; $i <= 255; $i++) {
518 518
 		if ($map[$i] != $ref[$i]) {
519
-			if ($i != $last+1) {
520
-				$s .= $i.' ';
519
+			if ($i != $last + 1) {
520
+				$s .= $i . ' ';
521 521
 			}
522 522
 			$last = $i;
523
-			$s .= '/'.$map[$i].' ';
523
+			$s .= '/' . $map[$i] . ' ';
524 524
 		}
525 525
 	}
526 526
 	return rtrim($s);
527 527
 }
528 528
 
529
-function SaveToFile($file, $s, $mode='t') {
530
-	$f = fopen($file, 'w'.$mode);
531
-	if(!$f) {
532
-		die('Can\'t write to file '.$file);
529
+function SaveToFile($file, $s, $mode = 't') {
530
+	$f = fopen($file, 'w' . $mode);
531
+	if (!$f) {
532
+		die('Can\'t write to file ' . $file);
533 533
 	}
534 534
 	fwrite($f, $s, strlen($s));
535 535
 	fclose($f);
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	//Check if font license allows embedding
550 550
 	$f = fopen($file, 'rb');
551 551
 	if (!$f) {
552
-		die('Error: unable to open '.$file);
552
+		die('Error: unable to open ' . $file);
553 553
 	}
554 554
 	//Extract number of tables
555 555
 	fseek($f, 4, SEEK_CUR);
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	$pp = ($fsType & 0x04) != 0;
579 579
 	$e = ($fsType & 0x08) != 0;
580 580
 	fclose($f);
581
-	if($rl AND (!$pp) AND (!$e)) {
581
+	if ($rl AND (!$pp) AND (!$e)) {
582 582
 		print "Warning: font license does not allow embedding\n";
583 583
 	}
584 584
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_tcpdf_5.0.002/qrcode.php 4 patches
Doc Comments   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     	 * Convert a string to an array (needed for PHP4 compatibility)
269 269
     	 * @param string $string The input string.
270 270
     	 * @param int $split_length Maximum length of the chunk.
271
-    	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
271
+    	 * @return  string[] the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272 272
     	 */
273 273
 		function str_split($string, $split_length=1) {
274 274
 			if ((strlen($string) > $split_length) OR (!$split_length)) {
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		/**
804 804
 		 * Get frame value at specified position
805 805
 		 * @param array $at x,y position
806
-		 * @return value at specified position
806
+		 * @return integer at specified position
807 807
 		 */
808 808
 		protected function getFrameAt($at) {
809 809
 			return ord($this->frame[$at['y']][$at['x']]);
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 		/**
947 947
 		 * Write Format Information on frame and returns the number of black bits
948 948
 		 * @param int $width frame width
949
-		 * @param array $frame frame
950
-		 * @param array $mask masking mode
949
+		 * @param integer $frame frame
950
+		 * @param integer $mask masking mode
951 951
 		 * @param int $level error correction level
952 952
 		 * @return int blacks
953 953
 		 */
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 		 * Return bitmask
1072 1072
 		 * @param int $maskNo mask number
1073 1073
 		 * @param int $width width
1074
-		 * @param array $frame frame
1074
+		 * @param integer $frame frame
1075 1075
 		 * @return array bitmask
1076 1076
 		 */
1077 1077
 		protected function generateMaskNo($maskNo, $width, $frame) {
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
 		 * @param array items input items
1704 1704
 		 * @param int $mode encoding mode.
1705 1705
 		 * @param int $size size of data (byte).
1706
-		 * @param array $data array of input data.
1706
+		 * @param string[] $data array of input data.
1707 1707
 		 * @return items
1708 1708
 		 *
1709 1709
 		 */
@@ -1792,7 +1792,7 @@  discard block
 block discarded – undo
1792 1792
 		/**
1793 1793
 		 * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).
1794 1794
 		 * @param int $c character value
1795
-		 * @return value
1795
+		 * @return integer
1796 1796
 		 */
1797 1797
 		protected function lookAnTable($c) {
1798 1798
 			return (($c > 127)?-1:$this->anTable[$c]);
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 
2095 2095
 		/**
2096 2096
 		 * mergeBitStream
2097
-		 * @param array $bstream
2097
+		 * @param integer $items
2098 2098
 		 * @return array bitstream
2099 2099
 		 */
2100 2100
 		 protected function mergeBitStream($items) {
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 
2232 2232
 		/**
2233 2233
 		 * Convert bitstream to bytes
2234
-		 * @param array $bitstream original bitstream
2234
+		 * @param array $bstream original bitstream
2235 2235
 		 * @return array of bytes
2236 2236
 		 */
2237 2237
 		 protected function bitstreamToByte($bstream) {
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 		 * Return an array of ECC specification.
2385 2385
 		 * @param int $version version
2386 2386
 		 * @param int $level error correction level
2387
-		 * @param array $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code}
2387
+		 * @param integer[] $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code}
2388 2388
 		 * @return array spec
2389 2389
 		 */
2390 2390
 		protected function getEccSpec($version, $level, $spec) {
@@ -2414,7 +2414,6 @@  discard block
 block discarded – undo
2414 2414
 		/**
2415 2415
 		 * Put an alignment marker.
2416 2416
 		 * @param array $frame frame
2417
-		 * @param int $width width
2418 2417
 		 * @param int $ox X center coordinate of the pattern
2419 2418
 		 * @param int $oy Y center coordinate of the pattern
2420 2419
 		 * @return array frame
@@ -2438,7 +2437,7 @@  discard block
 block discarded – undo
2438 2437
 		/**
2439 2438
 		 * Put an alignment pattern.
2440 2439
 		 * @param int $version version
2441
-		 * @param array $fram frame
2440
+		 * @param array $frame frame
2442 2441
 		 * @param int $width width
2443 2442
 		 * @return array frame
2444 2443
 		 */
@@ -2508,7 +2507,6 @@  discard block
 block discarded – undo
2508 2507
 		/**
2509 2508
 		 * Put a finder pattern.
2510 2509
 		 * @param array $frame frame
2511
-		 * @param int $width width
2512 2510
 		 * @param int $ox X center coordinate of the pattern
2513 2511
 		 * @param int $oy Y center coordinate of the pattern
2514 2512
 		 * @return array frame
@@ -2678,7 +2676,7 @@  discard block
 block discarded – undo
2678 2676
 		/**
2679 2677
 		 * Return data length
2680 2678
 		 * @param array $spec
2681
-		 * @return int value
2679
+		 * @return double value
2682 2680
 		 */
2683 2681
 		 protected function rsDataLength($spec) {
2684 2682
 			return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]);
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -173,29 +173,29 @@  discard block
 block discarded – undo
173 173
 	/**
174 174
 	 * Maximum matrix size for maximum version (version 40 is 177*177 matrix).
175 175
 	 */
176
-    define('QRSPEC_WIDTH_MAX', 177);
176
+	define('QRSPEC_WIDTH_MAX', 177);
177 177
 
178 178
 	// -----------------------------------------------------
179 179
 
180 180
 	/**
181 181
 	 * Matrix index to get width from $capacity array.
182 182
 	 */
183
-    define('QRCAP_WIDTH',    0);
183
+	define('QRCAP_WIDTH',    0);
184 184
 
185
-    /**
185
+	/**
186 186
 	 * Matrix index to get number of words from $capacity array.
187 187
 	 */
188
-    define('QRCAP_WORDS',    1);
188
+	define('QRCAP_WORDS',    1);
189 189
 
190
-    /**
190
+	/**
191 191
 	 * Matrix index to get remainder from $capacity array.
192 192
 	 */
193
-    define('QRCAP_REMINDER', 2);
193
+	define('QRCAP_REMINDER', 2);
194 194
 
195
-    /**
195
+	/**
196 196
 	 * Matrix index to get error correction level from $capacity array.
197 197
 	 */
198
-    define('QRCAP_EC',       3);
198
+	define('QRCAP_EC',       3);
199 199
 
200 200
 	// -----------------------------------------------------
201 201
 
@@ -204,33 +204,33 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * Number of header bits for structured mode
206 206
 	 */
207
-    define('STRUCTURE_HEADER_BITS',  20);
207
+	define('STRUCTURE_HEADER_BITS',  20);
208 208
 
209
-    /**
209
+	/**
210 210
 	 * Max number of symbols for structured mode
211 211
 	 */
212
-    define('MAX_STRUCTURED_SYMBOLS', 16);
212
+	define('MAX_STRUCTURED_SYMBOLS', 16);
213 213
 
214 214
 	// -----------------------------------------------------
215 215
 
216
-    // Masks
216
+	// Masks
217 217
 
218
-    /**
218
+	/**
219 219
 	 * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column)
220 220
 	 */
221
-    define('N1',  3);
221
+	define('N1',  3);
222 222
 
223
-    /**
223
+	/**
224 224
 	 * Down point base value for case 2 mask pattern (module block of same color)
225 225
 	 */
226 226
 	define('N2',  3);
227 227
 
228
-    /**
228
+	/**
229 229
 	 * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column)
230 230
 	 */
231 231
 	define('N3', 40);
232 232
 
233
-    /**
233
+	/**
234 234
 	 * Down point base value for case 4 mask pattern (ration of dark modules in whole)
235 235
 	 */
236 236
 	define('N4', 10);
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
 	// for compaibility with PHP4
266 266
 	if (!function_exists('str_split')) {
267
-    	/**
268
-    	 * Convert a string to an array (needed for PHP4 compatibility)
269
-    	 * @param string $string The input string.
270
-    	 * @param int $split_length Maximum length of the chunk.
271
-    	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272
-    	 */
267
+		/**
268
+		 * Convert a string to an array (needed for PHP4 compatibility)
269
+		 * @param string $string The input string.
270
+		 * @param int $split_length Maximum length of the chunk.
271
+		 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272
+		 */
273 273
 		function str_split($string, $split_length=1) {
274 274
 			if ((strlen($string) > $split_length) OR (!$split_length)) {
275 275
 				do {
@@ -2622,7 +2622,7 @@  discard block
 block discarded – undo
2622 2622
 		}
2623 2623
 
2624 2624
 		/**
2625
-		* Return block number 1
2625
+		 * Return block number 1
2626 2626
 		 * @param array $spec
2627 2627
 		 * @return int value
2628 2628
 		 */
Please login to merge, or discard this patch.
Spacing   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : qrcode.php
4 4
 // Begin       : 2010-03-22
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 	/**
181 181
 	 * Matrix index to get width from $capacity array.
182 182
 	 */
183
-    define('QRCAP_WIDTH',    0);
183
+    define('QRCAP_WIDTH', 0);
184 184
 
185 185
     /**
186 186
 	 * Matrix index to get number of words from $capacity array.
187 187
 	 */
188
-    define('QRCAP_WORDS',    1);
188
+    define('QRCAP_WORDS', 1);
189 189
 
190 190
     /**
191 191
 	 * Matrix index to get remainder from $capacity array.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     /**
196 196
 	 * Matrix index to get error correction level from $capacity array.
197 197
 	 */
198
-    define('QRCAP_EC',       3);
198
+    define('QRCAP_EC', 3);
199 199
 
200 200
 	// -----------------------------------------------------
201 201
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * Number of header bits for structured mode
206 206
 	 */
207
-    define('STRUCTURE_HEADER_BITS',  20);
207
+    define('STRUCTURE_HEADER_BITS', 20);
208 208
 
209 209
     /**
210 210
 	 * Max number of symbols for structured mode
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
     /**
219 219
 	 * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column)
220 220
 	 */
221
-    define('N1',  3);
221
+    define('N1', 3);
222 222
 
223 223
     /**
224 224
 	 * Down point base value for case 2 mask pattern (module block of same color)
225 225
 	 */
226
-	define('N2',  3);
226
+	define('N2', 3);
227 227
 
228 228
     /**
229 229
 	 * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column)
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     	 * @param int $split_length Maximum length of the chunk.
271 271
     	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272 272
     	 */
273
-		function str_split($string, $split_length=1) {
273
+		function str_split($string, $split_length = 1) {
274 274
 			if ((strlen($string) > $split_length) OR (!$split_length)) {
275 275
 				do {
276 276
 					$c = strlen($string);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
482 482
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
483 483
 			36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //
484
-			 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 44, -1, -1, -1, -1, -1, //
484
+			 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //
485 485
 			-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //
486 486
 			25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //
487 487
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
@@ -494,47 +494,47 @@  discard block
 block discarded – undo
494 494
 		 * @access protected
495 495
 		 */
496 496
 		protected $capacity = array(
497
-			array(  0,    0, 0, array(   0,    0,    0,    0)), //
498
-			array( 21,   26, 0, array(   7,   10,   13,   17)), //  1
499
-			array( 25,   44, 7, array(  10,   16,   22,   28)), //
500
-			array( 29,   70, 7, array(  15,   26,   36,   44)), //
501
-			array( 33,  100, 7, array(  20,   36,   52,   64)), //
502
-			array( 37,  134, 7, array(  26,   48,   72,   88)), //  5
503
-			array( 41,  172, 7, array(  36,   64,   96,  112)), //
504
-			array( 45,  196, 0, array(  40,   72,  108,  130)), //
505
-			array( 49,  242, 0, array(  48,   88,  132,  156)), //
506
-			array( 53,  292, 0, array(  60,  110,  160,  192)), //
507
-			array( 57,  346, 0, array(  72,  130,  192,  224)), // 10
508
-			array( 61,  404, 0, array(  80,  150,  224,  264)), //
509
-			array( 65,  466, 0, array(  96,  176,  260,  308)), //
510
-			array( 69,  532, 0, array( 104,  198,  288,  352)), //
511
-			array( 73,  581, 3, array( 120,  216,  320,  384)), //
512
-			array( 77,  655, 3, array( 132,  240,  360,  432)), // 15
513
-			array( 81,  733, 3, array( 144,  280,  408,  480)), //
514
-			array( 85,  815, 3, array( 168,  308,  448,  532)), //
515
-			array( 89,  901, 3, array( 180,  338,  504,  588)), //
516
-			array( 93,  991, 3, array( 196,  364,  546,  650)), //
517
-			array( 97, 1085, 3, array( 224,  416,  600,  700)), // 20
518
-			array(101, 1156, 4, array( 224,  442,  644,  750)), //
519
-			array(105, 1258, 4, array( 252,  476,  690,  816)), //
520
-			array(109, 1364, 4, array( 270,  504,  750,  900)), //
521
-			array(113, 1474, 4, array( 300,  560,  810,  960)), //
522
-			array(117, 1588, 4, array( 312,  588,  870, 1050)), // 25
523
-			array(121, 1706, 4, array( 336,  644,  952, 1110)), //
524
-			array(125, 1828, 4, array( 360,  700, 1020, 1200)), //
525
-			array(129, 1921, 3, array( 390,  728, 1050, 1260)), //
526
-			array(133, 2051, 3, array( 420,  784, 1140, 1350)), //
527
-			array(137, 2185, 3, array( 450,  812, 1200, 1440)), // 30
528
-			array(141, 2323, 3, array( 480,  868, 1290, 1530)), //
529
-			array(145, 2465, 3, array( 510,  924, 1350, 1620)), //
530
-			array(149, 2611, 3, array( 540,  980, 1440, 1710)), //
531
-			array(153, 2761, 3, array( 570, 1036, 1530, 1800)), //
532
-			array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35
533
-			array(161, 3034, 0, array( 600, 1120, 1680, 1980)), //
534
-			array(165, 3196, 0, array( 630, 1204, 1770, 2100)), //
535
-			array(169, 3362, 0, array( 660, 1260, 1860, 2220)), //
536
-			array(173, 3532, 0, array( 720, 1316, 1950, 2310)), //
537
-			array(177, 3706, 0, array( 750, 1372, 2040, 2430))  // 40
497
+			array(0, 0, 0, array(0, 0, 0, 0)), //
498
+			array(21, 26, 0, array(7, 10, 13, 17)), //  1
499
+			array(25, 44, 7, array(10, 16, 22, 28)), //
500
+			array(29, 70, 7, array(15, 26, 36, 44)), //
501
+			array(33, 100, 7, array(20, 36, 52, 64)), //
502
+			array(37, 134, 7, array(26, 48, 72, 88)), //  5
503
+			array(41, 172, 7, array(36, 64, 96, 112)), //
504
+			array(45, 196, 0, array(40, 72, 108, 130)), //
505
+			array(49, 242, 0, array(48, 88, 132, 156)), //
506
+			array(53, 292, 0, array(60, 110, 160, 192)), //
507
+			array(57, 346, 0, array(72, 130, 192, 224)), // 10
508
+			array(61, 404, 0, array(80, 150, 224, 264)), //
509
+			array(65, 466, 0, array(96, 176, 260, 308)), //
510
+			array(69, 532, 0, array(104, 198, 288, 352)), //
511
+			array(73, 581, 3, array(120, 216, 320, 384)), //
512
+			array(77, 655, 3, array(132, 240, 360, 432)), // 15
513
+			array(81, 733, 3, array(144, 280, 408, 480)), //
514
+			array(85, 815, 3, array(168, 308, 448, 532)), //
515
+			array(89, 901, 3, array(180, 338, 504, 588)), //
516
+			array(93, 991, 3, array(196, 364, 546, 650)), //
517
+			array(97, 1085, 3, array(224, 416, 600, 700)), // 20
518
+			array(101, 1156, 4, array(224, 442, 644, 750)), //
519
+			array(105, 1258, 4, array(252, 476, 690, 816)), //
520
+			array(109, 1364, 4, array(270, 504, 750, 900)), //
521
+			array(113, 1474, 4, array(300, 560, 810, 960)), //
522
+			array(117, 1588, 4, array(312, 588, 870, 1050)), // 25
523
+			array(121, 1706, 4, array(336, 644, 952, 1110)), //
524
+			array(125, 1828, 4, array(360, 700, 1020, 1200)), //
525
+			array(129, 1921, 3, array(390, 728, 1050, 1260)), //
526
+			array(133, 2051, 3, array(420, 784, 1140, 1350)), //
527
+			array(137, 2185, 3, array(450, 812, 1200, 1440)), // 30
528
+			array(141, 2323, 3, array(480, 868, 1290, 1530)), //
529
+			array(145, 2465, 3, array(510, 924, 1350, 1620)), //
530
+			array(149, 2611, 3, array(540, 980, 1440, 1710)), //
531
+			array(153, 2761, 3, array(570, 1036, 1530, 1800)), //
532
+			array(157, 2876, 0, array(570, 1064, 1590, 1890)), // 35
533
+			array(161, 3034, 0, array(600, 1120, 1680, 1980)), //
534
+			array(165, 3196, 0, array(630, 1204, 1770, 2100)), //
535
+			array(169, 3362, 0, array(660, 1260, 1860, 2220)), //
536
+			array(173, 3532, 0, array(720, 1316, 1950, 2310)), //
537
+			array(177, 3706, 0, array(750, 1372, 2040, 2430))  // 40
538 538
 		);
539 539
 
540 540
 		/**
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 		 */
544 544
 		protected $lengthTableBits = array(
545 545
 			array(10, 12, 14),
546
-			array( 9, 11, 13),
547
-			array( 8, 16, 16),
548
-			array( 8, 10, 12)
546
+			array(9, 11, 13),
547
+			array(8, 16, 16),
548
+			array(8, 10, 12)
549 549
 		);
550 550
 
551 551
 		/**
@@ -554,47 +554,47 @@  discard block
 block discarded – undo
554 554
 		 * @access protected
555 555
 		 */
556 556
 		protected $eccTable = array(
557
-			array(array( 0,  0), array( 0,  0), array( 0,  0), array( 0,  0)), //
558
-			array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)), //  1
559
-			array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)), //
560
-			array(array( 1,  0), array( 1,  0), array( 2,  0), array( 2,  0)), //
561
-			array(array( 1,  0), array( 2,  0), array( 2,  0), array( 4,  0)), //
562
-			array(array( 1,  0), array( 2,  0), array( 2,  2), array( 2,  2)), //  5
563
-			array(array( 2,  0), array( 4,  0), array( 4,  0), array( 4,  0)), //
564
-			array(array( 2,  0), array( 4,  0), array( 2,  4), array( 4,  1)), //
565
-			array(array( 2,  0), array( 2,  2), array( 4,  2), array( 4,  2)), //
566
-			array(array( 2,  0), array( 3,  2), array( 4,  4), array( 4,  4)), //
567
-			array(array( 2,  2), array( 4,  1), array( 6,  2), array( 6,  2)), // 10
568
-			array(array( 4,  0), array( 1,  4), array( 4,  4), array( 3,  8)), //
569
-			array(array( 2,  2), array( 6,  2), array( 4,  6), array( 7,  4)), //
570
-			array(array( 4,  0), array( 8,  1), array( 8,  4), array(12,  4)), //
571
-			array(array( 3,  1), array( 4,  5), array(11,  5), array(11,  5)), //
572
-			array(array( 5,  1), array( 5,  5), array( 5,  7), array(11,  7)), // 15
573
-			array(array( 5,  1), array( 7,  3), array(15,  2), array( 3, 13)), //
574
-			array(array( 1,  5), array(10,  1), array( 1, 15), array( 2, 17)), //
575
-			array(array( 5,  1), array( 9,  4), array(17,  1), array( 2, 19)), //
576
-			array(array( 3,  4), array( 3, 11), array(17,  4), array( 9, 16)), //
577
-			array(array( 3,  5), array( 3, 13), array(15,  5), array(15, 10)), // 20
578
-			array(array( 4,  4), array(17,  0), array(17,  6), array(19,  6)), //
579
-			array(array( 2,  7), array(17,  0), array( 7, 16), array(34,  0)), //
580
-			array(array( 4,  5), array( 4, 14), array(11, 14), array(16, 14)), //
581
-			array(array( 6,  4), array( 6, 14), array(11, 16), array(30,  2)), //
582
-			array(array( 8,  4), array( 8, 13), array( 7, 22), array(22, 13)), // 25
583
-			array(array(10,  2), array(19,  4), array(28,  6), array(33,  4)), //
584
-			array(array( 8,  4), array(22,  3), array( 8, 26), array(12, 28)), //
585
-			array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), //
586
-			array(array( 7,  7), array(21,  7), array( 1, 37), array(19, 26)), //
587
-			array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30
588
-			array(array(13,  3), array( 2, 29), array(42,  1), array(23, 28)), //
589
-			array(array(17,  0), array(10, 23), array(10, 35), array(19, 35)), //
590
-			array(array(17,  1), array(14, 21), array(29, 19), array(11, 46)), //
591
-			array(array(13,  6), array(14, 23), array(44,  7), array(59,  1)), //
592
-			array(array(12,  7), array(12, 26), array(39, 14), array(22, 41)), // 35
593
-			array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), //
594
-			array(array(17,  4), array(29, 14), array(49, 10), array(24, 46)), //
595
-			array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), //
596
-			array(array(20,  4), array(40,  7), array(43, 22), array(10, 67)), //
597
-			array(array(19,  6), array(18, 31), array(34, 34), array(20, 61))  // 40
557
+			array(array(0, 0), array(0, 0), array(0, 0), array(0, 0)), //
558
+			array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), //  1
559
+			array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), //
560
+			array(array(1, 0), array(1, 0), array(2, 0), array(2, 0)), //
561
+			array(array(1, 0), array(2, 0), array(2, 0), array(4, 0)), //
562
+			array(array(1, 0), array(2, 0), array(2, 2), array(2, 2)), //  5
563
+			array(array(2, 0), array(4, 0), array(4, 0), array(4, 0)), //
564
+			array(array(2, 0), array(4, 0), array(2, 4), array(4, 1)), //
565
+			array(array(2, 0), array(2, 2), array(4, 2), array(4, 2)), //
566
+			array(array(2, 0), array(3, 2), array(4, 4), array(4, 4)), //
567
+			array(array(2, 2), array(4, 1), array(6, 2), array(6, 2)), // 10
568
+			array(array(4, 0), array(1, 4), array(4, 4), array(3, 8)), //
569
+			array(array(2, 2), array(6, 2), array(4, 6), array(7, 4)), //
570
+			array(array(4, 0), array(8, 1), array(8, 4), array(12, 4)), //
571
+			array(array(3, 1), array(4, 5), array(11, 5), array(11, 5)), //
572
+			array(array(5, 1), array(5, 5), array(5, 7), array(11, 7)), // 15
573
+			array(array(5, 1), array(7, 3), array(15, 2), array(3, 13)), //
574
+			array(array(1, 5), array(10, 1), array(1, 15), array(2, 17)), //
575
+			array(array(5, 1), array(9, 4), array(17, 1), array(2, 19)), //
576
+			array(array(3, 4), array(3, 11), array(17, 4), array(9, 16)), //
577
+			array(array(3, 5), array(3, 13), array(15, 5), array(15, 10)), // 20
578
+			array(array(4, 4), array(17, 0), array(17, 6), array(19, 6)), //
579
+			array(array(2, 7), array(17, 0), array(7, 16), array(34, 0)), //
580
+			array(array(4, 5), array(4, 14), array(11, 14), array(16, 14)), //
581
+			array(array(6, 4), array(6, 14), array(11, 16), array(30, 2)), //
582
+			array(array(8, 4), array(8, 13), array(7, 22), array(22, 13)), // 25
583
+			array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), //
584
+			array(array(8, 4), array(22, 3), array(8, 26), array(12, 28)), //
585
+			array(array(3, 10), array(3, 23), array(4, 31), array(11, 31)), //
586
+			array(array(7, 7), array(21, 7), array(1, 37), array(19, 26)), //
587
+			array(array(5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30
588
+			array(array(13, 3), array(2, 29), array(42, 1), array(23, 28)), //
589
+			array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), //
590
+			array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), //
591
+			array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), //
592
+			array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35
593
+			array(array(6, 14), array(6, 34), array(46, 10), array(2, 64)), //
594
+			array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), //
595
+			array(array(4, 18), array(13, 32), array(48, 14), array(42, 32)), //
596
+			array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), //
597
+			array(array(19, 6), array(18, 31), array(34, 34), array(20, 61))  // 40
598 598
 		);
599 599
 
600 600
 		/**
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 		 * @access protected
605 605
 		 */
606 606
 		protected $alignmentPattern = array(
607
-			array( 0,  0),
608
-			array( 0,  0), array(18,  0), array(22,  0), array(26,  0), array(30,  0), //  1- 5
609
-			array(34,  0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), //  6-10
607
+			array(0, 0),
608
+			array(0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), //  1- 5
609
+			array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), //  6-10
610 610
 			array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15
611 611
 			array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20
612 612
 			array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 			foreach ($qrTab as $line) {
680 680
 				$arrAdd = array();
681 681
 				foreach (str_split($line) as $char) {
682
-					$arrAdd[] = ($char=='1')?1:0;
682
+					$arrAdd[] = ($char == '1') ? 1 : 0;
683 683
 				}
684 684
 				$barcode_array['bcode'][] = $arrAdd;
685 685
 			}
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 			$len = count($frame);
705 705
 			// the frame is square (width = height)
706 706
 			foreach ($frame as &$frameLine) {
707
-				for ($i=0; $i<$len; $i++) {
708
-					$frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0';
707
+				for ($i = 0; $i < $len; $i++) {
708
+					$frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0';
709 709
 				}
710 710
 			}
711 711
 			return $frame;
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 			$this->dir = -1;
756 756
 			$this->bit = -1;
757 757
 			// inteleaved data and ecc codes
758
-			for ($i=0; $i < ($this->dataLength + $this->eccLength); $i++) {
758
+			for ($i = 0; $i < ($this->dataLength + $this->eccLength); $i++) {
759 759
 				$code = $this->getCode();
760 760
 				$bit = 0x80;
761
-				for ($j=0; $j<8; $j++) {
761
+				for ($j = 0; $j < 8; $j++) {
762 762
 					$addr = $this->getNextPosition();
763 763
 					$this->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
764 764
 					$bit = $bit >> 1;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			}
767 767
 			// remainder bits
768 768
 			$j = $this->getRemainder($this->version);
769
-			for ($i=0; $i<$j; $i++) {
769
+			for ($i = 0; $i < $j; $i++) {
770 770
 				$addr = $this->getNextPosition();
771 771
 				$this->setFrameAt($addr, 0x02);
772 772
 			}
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 				}
857 857
 				$this->x = $x;
858 858
 				$this->y = $y;
859
-			} while(ord($this->frame[$y][$x]) & 0x80);
859
+			} while (ord($this->frame[$y][$x]) & 0x80);
860 860
 			return array('x'=>$x, 'y'=>$y);
861 861
 		}
862 862
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 			$dataPos = 0;
878 878
 			$eccPos = 0;
879 879
 			$endfor = $this->rsBlockNum1($spec);
880
-			for ($i=0; $i < $endfor; ++$i) {
880
+			for ($i = 0; $i < $endfor; ++$i) {
881 881
 				$ecc = array_slice($this->ecccode, $eccPos);
882 882
 				$this->rsblocks[$blockNo] = array();
883 883
 				$this->rsblocks[$blockNo]['dataLength'] = $dl;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 				$this->rsblocks[$blockNo]['eccLength'] = $el;
886 886
 				$ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
887 887
 				$this->rsblocks[$blockNo]['ecc'] = $ecc;
888
-				$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
888
+				$this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
889 889
 				$dataPos += $dl;
890 890
 				$eccPos += $el;
891 891
 				$blockNo++;
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 				return -1;
901 901
 			}
902 902
 			$endfor = $this->rsBlockNum2($spec);
903
-			for ($i=0; $i < $endfor; ++$i) {
903
+			for ($i = 0; $i < $endfor; ++$i) {
904 904
 				$ecc = array_slice($this->ecccode, $eccPos);
905 905
 				$this->rsblocks[$blockNo] = array();
906 906
 				$this->rsblocks[$blockNo]['dataLength'] = $dl;
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 		 */
954 954
 		 protected function writeFormatInformation($width, &$frame, $mask, $level) {
955 955
 			$blacks = 0;
956
-			$format =  $this->getFormatInfo($mask, $level);
957
-			for ($i=0; $i<8; ++$i) {
956
+			$format = $this->getFormatInfo($mask, $level);
957
+			for ($i = 0; $i < 8; ++$i) {
958 958
 				if ($format & 1) {
959 959
 					$blacks += 2;
960 960
 					$v = 0x85;
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				}
970 970
 				$format = $format >> 1;
971 971
 			}
972
-			for ($i=0; $i<7; ++$i) {
972
+			for ($i = 0; $i < 7; ++$i) {
973 973
 			if ($format & 1) {
974 974
 				$blacks += 2;
975 975
 				$v = 0x85;
@@ -1076,13 +1076,13 @@  discard block
 block discarded – undo
1076 1076
 		 */
1077 1077
 		protected function generateMaskNo($maskNo, $width, $frame) {
1078 1078
 			$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
1079
-			for ($y=0; $y<$width; ++$y) {
1080
-				for ($x=0; $x<$width; ++$x) {
1079
+			for ($y = 0; $y < $width; ++$y) {
1080
+				for ($x = 0; $x < $width; ++$x) {
1081 1081
 					if (ord($frame[$y][$x]) & 0x80) {
1082 1082
 						$bitMask[$y][$x] = 0;
1083 1083
 					} else {
1084
-						$maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
1085
-						$bitMask[$y][$x] = ($maskFunc == 0)?1:0;
1084
+						$maskFunc = call_user_func(array($this, 'mask' . $maskNo), $x, $y);
1085
+						$bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0;
1086 1086
 					}
1087 1087
 				}
1088 1088
 			}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		 * @param boolean $maskGenOnly
1099 1099
 		 * @return int b
1100 1100
 		 */
1101
-		 protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
1101
+		 protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) {
1102 1102
 			$b = 0;
1103 1103
 			$bitMask = array();
1104 1104
 			$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
@@ -1106,8 +1106,8 @@  discard block
 block discarded – undo
1106 1106
 				return;
1107 1107
 			}
1108 1108
 			$d = $s;
1109
-			for ($y=0; $y<$width; ++$y) {
1110
-				for ($x=0; $x<$width; ++$x) {
1109
+			for ($y = 0; $y < $width; ++$y) {
1110
+				for ($x = 0; $x < $width; ++$x) {
1111 1111
 					if ($bitMask[$y][$x] == 1) {
1112 1112
 						$d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
1113 1113
 					}
@@ -1139,20 +1139,20 @@  discard block
 block discarded – undo
1139 1139
 		 */
1140 1140
 		 protected function calcN1N3($length) {
1141 1141
 			$demerit = 0;
1142
-			for ($i=0; $i<$length; ++$i) {
1142
+			for ($i = 0; $i < $length; ++$i) {
1143 1143
 				if ($this->runLength[$i] >= 5) {
1144 1144
 					$demerit += (N1 + ($this->runLength[$i] - 5));
1145 1145
 				}
1146 1146
 				if ($i & 1) {
1147
-					if (($i >= 3) AND ($i < ($length-2)) AND ($this->runLength[$i] % 3 == 0)) {
1147
+					if (($i >= 3) AND ($i < ($length - 2)) AND ($this->runLength[$i] % 3 == 0)) {
1148 1148
 						$fact = (int)($this->runLength[$i] / 3);
1149
-						if (($this->runLength[$i-2] == $fact)
1150
-							AND ($this->runLength[$i-1] == $fact)
1151
-							AND ($this->runLength[$i+1] == $fact)
1152
-							AND ($this->runLength[$i+2] == $fact)) {
1153
-							if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) {
1149
+						if (($this->runLength[$i - 2] == $fact)
1150
+							AND ($this->runLength[$i - 1] == $fact)
1151
+							AND ($this->runLength[$i + 1] == $fact)
1152
+							AND ($this->runLength[$i + 2] == $fact)) {
1153
+							if (($this->runLength[$i - 3] < 0) OR ($this->runLength[$i - 3] >= (4 * $fact))) {
1154 1154
 								$demerit += N3;
1155
-							} elseif ((($i+3) >= $length) OR ($this->runLength[$i+3] >= (4 * $fact))) {
1155
+							} elseif ((($i + 3) >= $length) OR ($this->runLength[$i + 3] >= (4 * $fact))) {
1156 1156
 								$demerit += N3;
1157 1157
 							}
1158 1158
 						}
@@ -1171,17 +1171,17 @@  discard block
 block discarded – undo
1171 1171
 		 protected function evaluateSymbol($width, $frame) {
1172 1172
 			$head = 0;
1173 1173
 			$demerit = 0;
1174
-			for ($y=0; $y<$width; ++$y) {
1174
+			for ($y = 0; $y < $width; ++$y) {
1175 1175
 				$head = 0;
1176 1176
 				$this->runLength[0] = 1;
1177 1177
 				$frameY = $frame[$y];
1178 1178
 				if ($y > 0) {
1179
-					$frameYM = $frame[$y-1];
1179
+					$frameYM = $frame[$y - 1];
1180 1180
 				}
1181
-				for ($x=0; $x<$width; ++$x) {
1181
+				for ($x = 0; $x < $width; ++$x) {
1182 1182
 					if (($x > 0) AND ($y > 0)) {
1183
-						$b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
1184
-						$w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
1183
+						$b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]);
1184
+						$w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]);
1185 1185
 						if (($b22 | ($w22 ^ 1)) & 1) {
1186 1186
 							$demerit += N2;
1187 1187
 						}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 						$head = 1;
1192 1192
 						$this->runLength[$head] = 1;
1193 1193
 					} elseif ($x > 0) {
1194
-						if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
1194
+						if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) {
1195 1195
 							$head++;
1196 1196
 							$this->runLength[$head] = 1;
1197 1197
 						} else {
@@ -1199,18 +1199,18 @@  discard block
 block discarded – undo
1199 1199
 						}
1200 1200
 					}
1201 1201
 				}
1202
-				$demerit += $this->calcN1N3($head+1);
1202
+				$demerit += $this->calcN1N3($head + 1);
1203 1203
 			}
1204
-			for ($x=0; $x<$width; ++$x) {
1204
+			for ($x = 0; $x < $width; ++$x) {
1205 1205
 				$head = 0;
1206 1206
 				$this->runLength[0] = 1;
1207
-				for ($y=0; $y<$width; ++$y) {
1207
+				for ($y = 0; $y < $width; ++$y) {
1208 1208
 					if (($y == 0) AND (ord($frame[$y][$x]) & 1)) {
1209 1209
 						$this->runLength[0] = -1;
1210 1210
 						$head = 1;
1211 1211
 						$this->runLength[$head] = 1;
1212 1212
 					} elseif ($y > 0) {
1213
-						if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
1213
+						if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) {
1214 1214
 							$head++;
1215 1215
 							$this->runLength[$head] = 1;
1216 1216
 						} else {
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 						}
1219 1219
 					}
1220 1220
 				}
1221
-				$demerit += $this->calcN1N3($head+1);
1221
+				$demerit += $this->calcN1N3($head + 1);
1222 1222
 			}
1223 1223
 			return $demerit;
1224 1224
 		}
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 			$checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
1238 1238
 			if (QR_FIND_FROM_RANDOM !== false) {
1239 1239
 				$howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
1240
-				for ($i = 0; $i <  $howManuOut; ++$i) {
1241
-					$remPos = rand (0, count($checked_masks)-1);
1240
+				for ($i = 0; $i < $howManuOut; ++$i) {
1241
+					$remPos = rand(0, count($checked_masks) - 1);
1242 1242
 					unset($checked_masks[$remPos]);
1243 1243
 					$checked_masks = array_values($checked_masks);
1244 1244
 				}
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 			if ($pos >= strlen($str)) {
1277 1277
 				return false;
1278 1278
 			}
1279
-			return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
1279
+			return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')));
1280 1280
 		}
1281 1281
 
1282 1282
 		/**
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
 			} elseif ($this->isalnumat($this->dataStr, $pos)) {
1308 1308
 				return QR_MODE_AN;
1309 1309
 			} elseif ($this->hint == QR_MODE_KJ) {
1310
-				if ($pos+1 < strlen($this->dataStr)) {
1311
-					$d = $this->dataStr[$pos+1];
1310
+				if ($pos + 1 < strlen($this->dataStr)) {
1311
+					$d = $this->dataStr[$pos + 1];
1312 1312
 					$word = (ord($c) << 8) | ord($d);
1313 1313
 					if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) {
1314 1314
 						return QR_MODE_KJ;
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 		 protected function eatNum() {
1326 1326
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1327 1327
 			$p = 0;
1328
-			while($this->isdigitat($this->dataStr, $p)) {
1328
+			while ($this->isdigitat($this->dataStr, $p)) {
1329 1329
 				$p++;
1330 1330
 			}
1331 1331
 			$run = $p;
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 			if ($mode == QR_MODE_AN) {
1342 1342
 				$dif = $this->estimateBitsModeNum($run) + 4 + $ln
1343 1343
 				+ $this->estimateBitsModeAn(1)        // + 4 + la
1344
-				- $this->estimateBitsModeAn($run + 1);// - 4 - la
1344
+				- $this->estimateBitsModeAn($run + 1); // - 4 - la
1345 1345
 				if ($dif > 0) {
1346 1346
 					return $this->eatAn();
1347 1347
 				}
@@ -1355,13 +1355,13 @@  discard block
 block discarded – undo
1355 1355
 		 * @return int run
1356 1356
 		 */
1357 1357
 		 protected function eatAn() {
1358
-			$la = $this->lengthIndicator(QR_MODE_AN,  $this->version);
1358
+			$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
1359 1359
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1360 1360
 			$p = 0;
1361
-			while($this->isalnumat($this->dataStr, $p)) {
1361
+			while ($this->isalnumat($this->dataStr, $p)) {
1362 1362
 				if ($this->isdigitat($this->dataStr, $p)) {
1363 1363
 					$q = $p;
1364
-					while($this->isdigitat($this->dataStr, $q)) {
1364
+					while ($this->isdigitat($this->dataStr, $q)) {
1365 1365
 						$q++;
1366 1366
 					}
1367 1367
 					$dif = $this->estimateBitsModeAn($p) // + 4 + la
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 		 */
1396 1396
 		 protected function eatKanji() {
1397 1397
 			$p = 0;
1398
-			while($this->identifyMode($p) == QR_MODE_KJ) {
1398
+			while ($this->identifyMode($p) == QR_MODE_KJ) {
1399 1399
 				$p += 2;
1400 1400
 			}
1401 1401
 			$this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr));
@@ -1411,14 +1411,14 @@  discard block
 block discarded – undo
1411 1411
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1412 1412
 			$p = 1;
1413 1413
 			$dataStrLen = strlen($this->dataStr);
1414
-			while($p < $dataStrLen) {
1414
+			while ($p < $dataStrLen) {
1415 1415
 				$mode = $this->identifyMode($p);
1416 1416
 				if ($mode == QR_MODE_KJ) {
1417 1417
 					break;
1418 1418
 				}
1419 1419
 				if ($mode == QR_MODE_NM) {
1420 1420
 					$q = $p;
1421
-					while($this->isdigitat($this->dataStr, $q)) {
1421
+					while ($this->isdigitat($this->dataStr, $q)) {
1422 1422
 						$q++;
1423 1423
 					}
1424 1424
 					$dif = $this->estimateBitsMode8($p) // + 4 + l8
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 					}
1432 1432
 				} elseif ($mode == QR_MODE_AN) {
1433 1433
 					$q = $p;
1434
-					while($this->isalnumat($this->dataStr, $q)) {
1434
+					while ($this->isalnumat($this->dataStr, $q)) {
1435 1435
 						$q++;
1436 1436
 					}
1437 1437
 					$dif = $this->estimateBitsMode8($p)  // + 4 + l8
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
 		 * @param array $bstream
1525 1525
 		 * @return array input item
1526 1526
 		 */
1527
-		 protected function newInputItem($mode, $size, $data, $bstream=null) {
1527
+		 protected function newInputItem($mode, $size, $data, $bstream = null) {
1528 1528
 			$setData = array_slice($data, 0, $size);
1529 1529
 			if (count($setData) < $size) {
1530 1530
 				$setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0));
@@ -1552,18 +1552,18 @@  discard block
 block discarded – undo
1552 1552
 			$val = 0x1;
1553 1553
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
1554 1554
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']);
1555
-			for ($i=0; $i < $words; ++$i) {
1556
-				$val  = (ord($inputitem['data'][$i*3  ]) - ord('0')) * 100;
1557
-				$val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10;
1558
-				$val += (ord($inputitem['data'][$i*3+2]) - ord('0'));
1555
+			for ($i = 0; $i < $words; ++$i) {
1556
+				$val  = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100;
1557
+				$val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10;
1558
+				$val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0'));
1559 1559
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val);
1560 1560
 			}
1561 1561
 			if ($inputitem['size'] - $words * 3 == 1) {
1562
-				$val = ord($inputitem['data'][$words*3]) - ord('0');
1562
+				$val = ord($inputitem['data'][$words * 3]) - ord('0');
1563 1563
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
1564 1564
 			} elseif (($inputitem['size'] - ($words * 3)) == 2) {
1565
-				$val  = (ord($inputitem['data'][$words*3  ]) - ord('0')) * 10;
1566
-				$val += (ord($inputitem['data'][$words*3+1]) - ord('0'));
1565
+				$val  = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10;
1566
+				$val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0'));
1567 1567
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val);
1568 1568
 			}
1569 1569
 			return $inputitem;
@@ -1580,9 +1580,9 @@  discard block
 block discarded – undo
1580 1580
 			$inputitem['bstream'] = array();
1581 1581
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02);
1582 1582
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']); //DEBUG
1583
-			for ($i=0; $i < $words; ++$i) {
1584
-				$val  = (int)$this->lookAnTable(ord($inputitem['data'][$i*2  ])) * 45;
1585
-				$val += (int)$this->lookAnTable(ord($inputitem['data'][$i*2+1]));
1583
+			for ($i = 0; $i < $words; ++$i) {
1584
+				$val  = (int)$this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45;
1585
+				$val += (int)$this->lookAnTable(ord($inputitem['data'][$i * 2 + 1]));
1586 1586
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val);
1587 1587
 			}
1588 1588
 			if ($inputitem['size'] & 1) {
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 			$inputitem['bstream'] = array();
1603 1603
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4);
1604 1604
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']);
1605
-			for ($i=0; $i < $inputitem['size']; ++$i) {
1605
+			for ($i = 0; $i < $inputitem['size']; ++$i) {
1606 1606
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i]));
1607 1607
 			}
1608 1608
 			return $inputitem;
@@ -1618,8 +1618,8 @@  discard block
 block discarded – undo
1618 1618
 			$inputitem['bstream'] = array();
1619 1619
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8);
1620 1620
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2));
1621
-			for ($i=0; $i<$inputitem['size']; $i+=2) {
1622
-				$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]);
1621
+			for ($i = 0; $i < $inputitem['size']; $i += 2) {
1622
+				$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i + 1]);
1623 1623
 				if ($val <= 0x9ffc) {
1624 1624
 					$val -= 0x8140;
1625 1625
 				} else {
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 				$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']);
1665 1665
 				$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']);
1666 1666
 			} else {
1667
-				switch($inputitem['mode']) {
1667
+				switch ($inputitem['mode']) {
1668 1668
 					case QR_MODE_NM: {
1669 1669
 						$inputitem = $this->encodeModeNum($inputitem, $version);
1670 1670
 						break;
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
 			$parity = 0;
1743 1743
 			foreach ($items as $item) {
1744 1744
 				if ($item['mode'] != QR_MODE_ST) {
1745
-					for ($i=$item['size']-1; $i>=0; --$i) {
1745
+					for ($i = $item['size'] - 1; $i >= 0; --$i) {
1746 1746
 						$parity ^= $item['data'][$i];
1747 1747
 					}
1748 1748
 				}
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 		 * @return boolean true or false
1758 1758
 		 */
1759 1759
 		 protected function checkModeNum($size, $data) {
1760
-			for ($i=0; $i<$size; ++$i) {
1761
-				if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){
1760
+			for ($i = 0; $i < $size; ++$i) {
1761
+				if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))) {
1762 1762
 					return false;
1763 1763
 				}
1764 1764
 			}
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		 protected function estimateBitsModeNum($size) {
1774 1774
 			$w = (int)$size / 3;
1775 1775
 			$bits = $w * 10;
1776
-			switch($size - $w * 3) {
1776
+			switch ($size - $w * 3) {
1777 1777
 				case 1: {
1778 1778
 					$bits += 4;
1779 1779
 					break;
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
 		 * @return value
1796 1796
 		 */
1797 1797
 		protected function lookAnTable($c) {
1798
-			return (($c > 127)?-1:$this->anTable[$c]);
1798
+			return (($c > 127) ?-1 : $this->anTable[$c]);
1799 1799
 		}
1800 1800
 
1801 1801
 		/**
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
 		 * @return boolean true or false
1806 1806
 		 */
1807 1807
 		 protected function checkModeAn($size, $data) {
1808
-			for ($i=0; $i<$size; ++$i) {
1808
+			for ($i = 0; $i < $size; ++$i) {
1809 1809
 				if ($this->lookAnTable(ord($data[$i])) == -1) {
1810 1810
 					return false;
1811 1811
 				}
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
 			if ($size & 1) {
1856 1856
 				return false;
1857 1857
 			}
1858
-			for ($i=0; $i<$size; $i+=2) {
1859
-				$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
1858
+			for ($i = 0; $i < $size; $i += 2) {
1859
+				$val = (ord($data[$i]) << 8) | ord($data[$i + 1]);
1860 1860
 				if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) {
1861 1861
 					return false;
1862 1862
 				}
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 			if ($size <= 0) {
1876 1876
 				return false;
1877 1877
 			}
1878
-			switch($mode) {
1878
+			switch ($mode) {
1879 1879
 				case QR_MODE_NM: {
1880 1880
 					return $this->checkModeNum($size, $data);
1881 1881
 				}
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 				$version = 1;
1911 1911
 			}
1912 1912
 			foreach ($items as $item) {
1913
-				switch($item['mode']) {
1913
+				switch ($item['mode']) {
1914 1914
 					case QR_MODE_NM: {
1915 1915
 						$bits = $this->estimateBitsModeNum($item['size']);
1916 1916
 						break;
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
 		 */
1971 1971
 		 protected function lengthOfCode($mode, $version, $bits) {
1972 1972
 			$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
1973
-			switch($mode) {
1973
+			switch ($mode) {
1974 1974
 				case QR_MODE_NM: {
1975 1975
 					$chunks = (int)($payload / 10);
1976 1976
 					$remain = $payload - $chunks * 10;
@@ -2084,8 +2084,8 @@  discard block
 block discarded – undo
2084 2084
 			$padlen = $maxwords - $words;
2085 2085
 			if ($padlen > 0) {
2086 2086
 				$padbuf = array();
2087
-				for ($i=0; $i<$padlen; ++$i) {
2088
-					$padbuf[$i] = ($i&1)?0x11:0xec;
2087
+				for ($i = 0; $i < $padlen; ++$i) {
2088
+					$padbuf[$i] = ($i & 1) ? 0x11 : 0xec;
2089 2089
 				}
2090 2090
 				$padding = $this->appendBytes($padding, $padlen, $padbuf);
2091 2091
 			}
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 		 protected function newFromNum($bits, $num) {
2149 2149
 			$bstream = $this->allocate($bits);
2150 2150
 			$mask = 1 << ($bits - 1);
2151
-			for ($i=0; $i<$bits; ++$i) {
2151
+			for ($i = 0; $i < $bits; ++$i) {
2152 2152
 				if ($num & $mask) {
2153 2153
 					$bstream[$i] = 1;
2154 2154
 				} else {
@@ -2167,10 +2167,10 @@  discard block
 block discarded – undo
2167 2167
 		 */
2168 2168
 		 protected function newFromBytes($size, $data) {
2169 2169
 			$bstream = $this->allocate($size * 8);
2170
-			$p=0;
2171
-			for ($i=0; $i<$size; ++$i) {
2170
+			$p = 0;
2171
+			for ($i = 0; $i < $size; ++$i) {
2172 2172
 				$mask = 0x80;
2173
-				for ($j=0; $j<8; ++$j) {
2173
+				for ($j = 0; $j < 8; ++$j) {
2174 2174
 					if ($data[$i] & $mask) {
2175 2175
 						$bstream[$p] = 1;
2176 2176
 					} else {
@@ -2242,9 +2242,9 @@  discard block
 block discarded – undo
2242 2242
 			$data = array_fill(0, (int)(($size + 7) / 8), 0);
2243 2243
 			$bytes = (int)($size / 8);
2244 2244
 			$p = 0;
2245
-			for ($i=0; $i<$bytes; $i++) {
2245
+			for ($i = 0; $i < $bytes; $i++) {
2246 2246
 				$v = 0;
2247
-				for ($j=0; $j<8; $j++) {
2247
+				for ($j = 0; $j < 8; $j++) {
2248 2248
 					$v = $v << 1;
2249 2249
 					$v |= $bstream[$p];
2250 2250
 					$p++;
@@ -2253,7 +2253,7 @@  discard block
 block discarded – undo
2253 2253
 			}
2254 2254
 			if ($size & 7) {
2255 2255
 				$v = 0;
2256
-				for ($j=0; $j<($size & 7); $j++) {
2256
+				for ($j = 0; $j < ($size & 7); $j++) {
2257 2257
 					$v = $v << 1;
2258 2258
 					$v |= $bstream[$p];
2259 2259
 					$p++;
@@ -2276,8 +2276,8 @@  discard block
 block discarded – undo
2276 2276
 		 * @param int $replLen length of the repl string
2277 2277
 		 * @return array srctab
2278 2278
 		 */
2279
-		 protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
2280
-			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
2279
+		 protected function qrstrset($srctab, $x, $y, $repl, $replLen = false) {
2280
+			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl));
2281 2281
 			return $srctab;
2282 2282
 		}
2283 2283
 
@@ -2297,7 +2297,7 @@  discard block
 block discarded – undo
2297 2297
 		 * @param int $level error correction level
2298 2298
 		 * @return int ECC size (bytes)
2299 2299
 		 */
2300
-		protected function getECCLength($version, $level){
2300
+		protected function getECCLength($version, $level) {
2301 2301
 			return $this->capacity[$version][QRCAP_EC][$level];
2302 2302
 		}
2303 2303
 
@@ -2326,8 +2326,8 @@  discard block
 block discarded – undo
2326 2326
 		 * @return int version number
2327 2327
 		 */
2328 2328
 		protected function getMinimumVersion($size, $level) {
2329
-			for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) {
2330
-				$words  = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
2329
+			for ($i = 1; $i <= QRSPEC_VERSION_MAX; ++$i) {
2330
+				$words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
2331 2331
 				if ($words >= $size) {
2332 2332
 					return $i;
2333 2333
 				}
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
 			} else {
2405 2405
 				$spec[0] = $b1;
2406 2406
 				$spec[1] = (int)($data / ($b1 + $b2));
2407
-				$spec[2] = (int)($ecc  / ($b1 + $b2));
2407
+				$spec[2] = (int)($ecc / ($b1 + $b2));
2408 2408
 				$spec[3] = $b2;
2409 2409
 				$spec[4] = $spec[1] + 1;
2410 2410
 			}
@@ -2429,8 +2429,8 @@  discard block
 block discarded – undo
2429 2429
 				);
2430 2430
 			$yStart = $oy - 2;
2431 2431
 			$xStart = $ox - 2;
2432
-			for ($y=0; $y < 5; $y++) {
2433
-				$frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]);
2432
+			for ($y = 0; $y < 5; $y++) {
2433
+				$frame = $this->qrstrset($frame, $xStart, $yStart + $y, $finder[$y]);
2434 2434
 			}
2435 2435
 			return $frame;
2436 2436
 		}
@@ -2460,15 +2460,15 @@  discard block
 block discarded – undo
2460 2460
 			}
2461 2461
 			$cx = $this->alignmentPattern[$version][0];
2462 2462
 			$wo = $w - 1;
2463
-			for ($x=1; $x < $wo; ++$x) {
2463
+			for ($x = 1; $x < $wo; ++$x) {
2464 2464
 				$frame = $this->putAlignmentMarker($frame, 6, $cx);
2465
-				$frame = $this->putAlignmentMarker($frame, $cx,  6);
2465
+				$frame = $this->putAlignmentMarker($frame, $cx, 6);
2466 2466
 				$cx += $d;
2467 2467
 			}
2468 2468
 			$cy = $this->alignmentPattern[$version][0];
2469
-			for ($y=0; $y < $wo; ++$y) {
2469
+			for ($y = 0; $y < $wo; ++$y) {
2470 2470
 				$cx = $this->alignmentPattern[$version][0];
2471
-				for ($x=0; $x < $wo; ++$x) {
2471
+				for ($x = 0; $x < $wo; ++$x) {
2472 2472
 					$frame = $this->putAlignmentMarker($frame, $cx, $cy);
2473 2473
 					$cx += $d;
2474 2474
 				}
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
 			"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
2524 2524
 			"\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
2525 2525
 			);
2526
-			for ($y=0; $y < 7; $y++) {
2526
+			for ($y = 0; $y < 7; $y++) {
2527 2527
 				$frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]);
2528 2528
 			}
2529 2529
 			return $frame;
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 		 */
2537 2537
 		protected function createFrame($version) {
2538 2538
 			$width = $this->capacity[$version][QRCAP_WIDTH];
2539
-			$frameLine = str_repeat ("\0", $width);
2539
+			$frameLine = str_repeat("\0", $width);
2540 2540
 			$frame = array_fill(0, $width, $frameLine);
2541 2541
 			// Finder pattern
2542 2542
 			$frame = $this->putFinderPattern($frame, 0, 0);
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 			$frame = $this->putFinderPattern($frame, 0, $width - 7);
2545 2545
 			// Separator
2546 2546
 			$yOffset = $width - 7;
2547
-			for ($y=0; $y < 7; ++$y) {
2547
+			for ($y = 0; $y < 7; ++$y) {
2548 2548
 				$frame[$y][7] = "\xc0";
2549 2549
 				$frame[$y][$width - 8] = "\xc0";
2550 2550
 				$frame[$yOffset][7] = "\xc0";
@@ -2552,22 +2552,22 @@  discard block
 block discarded – undo
2552 2552
 			}
2553 2553
 			$setPattern = str_repeat("\xc0", 8);
2554 2554
 			$frame = $this->qrstrset($frame, 0, 7, $setPattern);
2555
-			$frame = $this->qrstrset($frame, $width-8, 7, $setPattern);
2555
+			$frame = $this->qrstrset($frame, $width - 8, 7, $setPattern);
2556 2556
 			$frame = $this->qrstrset($frame, 0, $width - 8, $setPattern);
2557 2557
 			// Format info
2558 2558
 			$setPattern = str_repeat("\x84", 9);
2559 2559
 			$frame = $this->qrstrset($frame, 0, 8, $setPattern);
2560 2560
 			$frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8);
2561 2561
 			$yOffset = $width - 8;
2562
-			for ($y=0; $y < 8; ++$y,++$yOffset) {
2562
+			for ($y = 0; $y < 8; ++$y, ++$yOffset) {
2563 2563
 				$frame[$y][8] = "\x84";
2564 2564
 				$frame[$yOffset][8] = "\x84";
2565 2565
 			}
2566 2566
 			// Timing pattern
2567 2567
 			$wo = $width - 15;
2568
-			for ($i=1; $i < $wo; ++$i) {
2569
-				$frame[6][7+$i] = chr(0x90 | ($i & 1));
2570
-				$frame[7+$i][6] = chr(0x90 | ($i & 1));
2568
+			for ($i = 1; $i < $wo; ++$i) {
2569
+				$frame[6][7 + $i] = chr(0x90 | ($i & 1));
2570
+				$frame[7 + $i][6] = chr(0x90 | ($i & 1));
2571 2571
 			}
2572 2572
 			// Alignment pattern
2573 2573
 			$frame = $this->putAlignmentPattern($version, $frame, $width);
@@ -2575,16 +2575,16 @@  discard block
 block discarded – undo
2575 2575
 			if ($version >= 7) {
2576 2576
 				$vinf = $this->getVersionPattern($version);
2577 2577
 				$v = $vinf;
2578
-				for ($x=0; $x<6; ++$x) {
2579
-					for ($y=0; $y<3; ++$y) {
2580
-						$frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
2578
+				for ($x = 0; $x < 6; ++$x) {
2579
+					for ($y = 0; $y < 3; ++$y) {
2580
+						$frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1));
2581 2581
 						$v = $v >> 1;
2582 2582
 					}
2583 2583
 				}
2584 2584
 				$v = $vinf;
2585
-				for ($y=0; $y<6; ++$y) {
2586
-					for ($x=0; $x<3; ++$x) {
2587
-						$frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
2585
+				for ($y = 0; $y < 6; ++$y) {
2586
+					for ($x = 0; $x < 3; ++$x) {
2587
+						$frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1));
2588 2588
 						$v = $v >> 1;
2589 2589
 					}
2590 2590
 				}
@@ -2755,16 +2755,16 @@  discard block
 block discarded – undo
2755 2755
 			if (($symsize < 0) OR ($symsize > 8)) {
2756 2756
 				return $rs;
2757 2757
 			}
2758
-			if (($fcr < 0) OR ($fcr >= (1<<$symsize))) {
2758
+			if (($fcr < 0) OR ($fcr >= (1 << $symsize))) {
2759 2759
 				return $rs;
2760 2760
 			}
2761
-			if (($prim <= 0) OR ($prim >= (1<<$symsize))) {
2761
+			if (($prim <= 0) OR ($prim >= (1 << $symsize))) {
2762 2762
 				return $rs;
2763 2763
 			}
2764
-			if (($nroots < 0) OR ($nroots >= (1<<$symsize))) {
2764
+			if (($nroots < 0) OR ($nroots >= (1 << $symsize))) {
2765 2765
 				return $rs;
2766 2766
 			}
2767
-			if (($pad < 0) OR ($pad >= ((1<<$symsize) -1 - $nroots))) {
2767
+			if (($pad < 0) OR ($pad >= ((1 << $symsize) - 1 - $nroots))) {
2768 2768
 				return $rs;
2769 2769
 			}
2770 2770
 			$rs = array();
@@ -2774,13 +2774,13 @@  discard block
 block discarded – undo
2774 2774
 			$rs['alpha_to'] = array_fill(0, ($rs['nn'] + 1), 0);
2775 2775
 			$rs['index_of'] = array_fill(0, ($rs['nn'] + 1), 0);
2776 2776
 			// PHP style macro replacement ;)
2777
-			$NN =& $rs['nn'];
2778
-			$A0 =& $NN;
2777
+			$NN = & $rs['nn'];
2778
+			$A0 = & $NN;
2779 2779
 			// Generate Galois field lookup tables
2780 2780
 			$rs['index_of'][0] = $A0; // log(zero) = -inf
2781 2781
 			$rs['alpha_to'][$A0] = 0; // alpha**-inf = 0
2782 2782
 			$sr = 1;
2783
-			for ($i=0; $i<$rs['nn']; ++$i) {
2783
+			for ($i = 0; $i < $rs['nn']; ++$i) {
2784 2784
 				$rs['index_of'][$sr] = $i;
2785 2785
 				$rs['alpha_to'][$i] = $sr;
2786 2786
 				$sr <<= 1;
@@ -2800,21 +2800,21 @@  discard block
 block discarded – undo
2800 2800
 			$rs['nroots'] = $nroots;
2801 2801
 			$rs['gfpoly'] = $gfpoly;
2802 2802
 			// Find prim-th root of 1, used in decoding
2803
-			for ($iprim=1; ($iprim % $prim) != 0; $iprim += $rs['nn']) {
2803
+			for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs['nn']) {
2804 2804
 				; // intentional empty-body loop!
2805 2805
 			}
2806 2806
 			$rs['iprim'] = (int)($iprim / $prim);
2807 2807
 			$rs['genpoly'][0] = 1;
2808 2808
 
2809 2809
 
2810
-			for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) {
2811
-				$rs['genpoly'][$i+1] = 1;
2810
+			for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) {
2811
+				$rs['genpoly'][$i + 1] = 1;
2812 2812
 				// Multiply rs->genpoly[] by  @**(root + x)
2813 2813
 				for ($j = $i; $j > 0; --$j) {
2814 2814
 					if ($rs['genpoly'][$j] != 0) {
2815
-						$rs['genpoly'][$j] = $rs['genpoly'][$j-1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)];
2815
+						$rs['genpoly'][$j] = $rs['genpoly'][$j - 1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)];
2816 2816
 					} else {
2817
-						$rs['genpoly'][$j] = $rs['genpoly'][$j-1];
2817
+						$rs['genpoly'][$j] = $rs['genpoly'][$j - 1];
2818 2818
 					}
2819 2819
 				}
2820 2820
 				// rs->genpoly[0] can never be zero
@@ -2835,26 +2835,26 @@  discard block
 block discarded – undo
2835 2835
 		 * @return parity array
2836 2836
 		 */
2837 2837
 		 protected function encode_rs_char($rs, $data, $parity) {
2838
-			$MM       =& $rs['mm']; // bits per symbol
2839
-			$NN       =& $rs['nn']; // the total number of symbols in a RS block
2840
-			$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
2841
-			$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
2842
-			$GENPOLY  =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
2843
-			$NROOTS   =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
2844
-			$FCR      =& $rs['fcr']; // first consecutive root, index form
2845
-			$PRIM     =& $rs['prim']; // primitive element, index form
2846
-			$IPRIM    =& $rs['iprim']; // prim-th root of 1, index form
2847
-			$PAD      =& $rs['pad']; // the number of pad symbols in a block
2848
-			$A0       =& $NN;
2838
+			$MM       = & $rs['mm']; // bits per symbol
2839
+			$NN       = & $rs['nn']; // the total number of symbols in a RS block
2840
+			$ALPHA_TO = & $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
2841
+			$INDEX_OF = & $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
2842
+			$GENPOLY  = & $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
2843
+			$NROOTS   = & $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
2844
+			$FCR      = & $rs['fcr']; // first consecutive root, index form
2845
+			$PRIM     = & $rs['prim']; // primitive element, index form
2846
+			$IPRIM    = & $rs['iprim']; // prim-th root of 1, index form
2847
+			$PAD      = & $rs['pad']; // the number of pad symbols in a block
2848
+			$A0       = & $NN;
2849 2849
 			$parity = array_fill(0, $NROOTS, 0);
2850
-			for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) {
2850
+			for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) {
2851 2851
 				$feedback = $INDEX_OF[$data[$i] ^ $parity[0]];
2852 2852
 				if ($feedback != $A0) {
2853 2853
 					// feedback term is non-zero
2854 2854
 					// This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
2855 2855
 					// always be for the polynomials constructed by init_rs()
2856 2856
 					$feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback);
2857
-					for ($j=1; $j < $NROOTS; ++$j) {
2857
+					for ($j = 1; $j < $NROOTS; ++$j) {
2858 2858
 					$parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])];
2859 2859
 					}
2860 2860
 				}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.