Code Duplication    Length = 95-95 lines in 2 locations

fpdf/chinese.php 1 location

@@ 129-223 (lines=95) @@
126
    parent::MultiCell($w,$h,$txt,$border,$align,$fill);
127
}
128
129
function MBMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0)
130
{
131
  //Multi-byte version of MultiCell()
132
  $cw=&$this->CurrentFont['cw'];
133
  if($w==0)
134
    $w=$this->w-$this->rMargin-$this->x;
135
  $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
136
  $s=str_replace("\r",'',$txt);
137
  $nb=strlen($s);
138
  if($nb>0 and $s[$nb-1]=="\n")
139
    $nb--;
140
  $b=0;
141
  if($border)
142
  {
143
    if($border==1)
144
    {
145
      $border='LTRB';
146
      $b='LRT';
147
      $b2='LR';
148
    }
149
    else
150
    {
151
      $b2='';
152
      if(is_int(strpos($border,'L')))
153
        $b2.='L';
154
      if(is_int(strpos($border,'R')))
155
        $b2.='R';
156
      $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
157
    }
158
  }
159
  $sep=-1;
160
  $i=0;
161
  $j=0;
162
  $l=0;
163
  $nl=1;
164
  while($i<$nb)
165
  {
166
    //Get next character
167
    $c=$s[$i];
168
    //Check if ASCII or MB
169
    $ascii=(ord($c)<128);
170
    if($c=="\n")
171
    {
172
      //Explicit line break
173
      $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
174
      $i++;
175
      $sep=-1;
176
      $j=$i;
177
      $l=0;
178
      $nl++;
179
      if($border and $nl==2)
180
        $b=$b2;
181
      continue;
182
    }
183
    if(!$ascii)
184
    {
185
      $sep=$i;
186
      $ls=$l;
187
    }
188
    elseif($c==' ')
189
    {
190
      $sep=$i;
191
      $ls=$l;
192
    }
193
    $l+=$ascii ? $cw[$c] : 1000;
194
    if($l>$wmax)
195
    {
196
      //Automatic line break
197
      if($sep==-1 or $i==$j)
198
      {
199
        if($i==$j)
200
          $i+=$ascii ? 1 : 2;
201
        $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
202
      }
203
      else
204
      {
205
        $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
206
        $i=($s[$sep]==' ') ? $sep+1 : $sep;
207
      }
208
      $sep=-1;
209
      $j=$i;
210
      $l=0;
211
      $nl++;
212
      if($border and $nl==2)
213
        $b=$b2;
214
    }
215
    else
216
      $i+=$ascii ? 1 : 2;
217
  }
218
  //Last chunk
219
  if($border and is_int(strpos($border,'B')))
220
    $b.='B';
221
  $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
222
  $this->x=$this->lMargin;
223
}
224
225
function Write($h,$txt,$link='')
226
{

fpdf/korean.php 1 location

@@ 99-193 (lines=95) @@
96
    parent::MultiCell($w,$h,$txt,$border,$align,$fill);
97
}
98
99
function MBMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0)
100
{
101
  //Multi-byte version of MultiCell()
102
  $cw=&$this->CurrentFont['cw'];
103
  if($w==0)
104
    $w=$this->w-$this->rMargin-$this->x;
105
  $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
106
  $s=str_replace("\r",'',$txt);
107
  $nb=strlen($s);
108
  if($nb>0 and $s[$nb-1]=="\n")
109
    $nb--;
110
  $b=0;
111
  if($border)
112
  {
113
    if($border==1)
114
    {
115
      $border='LTRB';
116
      $b='LRT';
117
      $b2='LR';
118
    }
119
    else
120
    {
121
      $b2='';
122
      if(is_int(strpos($border,'L')))
123
        $b2.='L';
124
      if(is_int(strpos($border,'R')))
125
        $b2.='R';
126
      $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
127
    }
128
  }
129
  $sep=-1;
130
  $i=0;
131
  $j=0;
132
  $l=0;
133
  $nl=1;
134
  while($i<$nb)
135
  {
136
    //Get next character
137
    $c=$s[$i];
138
    //Check if ASCII or MB
139
    $ascii=(ord($c)<128);
140
    if($c=="\n")
141
    {
142
      //Explicit line break
143
      $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
144
      $i++;
145
      $sep=-1;
146
      $j=$i;
147
      $l=0;
148
      $nl++;
149
      if($border and $nl==2)
150
        $b=$b2;
151
      continue;
152
    }
153
    if(!$ascii)
154
    {
155
      $sep=$i;
156
      $ls=$l;
157
    }
158
    elseif($c==' ')
159
    {
160
      $sep=$i;
161
      $ls=$l;
162
    }
163
    $l+=$ascii ? $cw[$c] : 1000;
164
    if($l>$wmax)
165
    {
166
      //Automatic line break
167
      if($sep==-1 or $i==$j)
168
      {
169
        if($i==$j)
170
          $i+=$ascii ? 1 : 2;
171
        $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
172
      }
173
      else
174
      {
175
        $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
176
        $i=($s[$sep]==' ') ? $sep+1 : $sep;
177
      }
178
      $sep=-1;
179
      $j=$i;
180
      $l=0;
181
      $nl++;
182
      if($border and $nl==2)
183
        $b=$b2;
184
    }
185
    else
186
      $i+=$ascii ? 1 : 2;
187
  }
188
  //Last chunk
189
  if($border and is_int(strpos($border,'B')))
190
    $b.='B';
191
  $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
192
  $this->x=$this->lMargin;
193
}
194
195
function Write($h,$txt,$link='')
196
{