Example #1
0
 /**
  * Output an HTML list bullet or ordered item symbol
  * @param $listdepth (int) list nesting level
  * @param $listtype (string) type of list
  * @param $size (float) current font size
  * @protected
  * @since 4.4.004 (2008-12-10)
  */
 protected function putHtmlListBullet($listdepth, $listtype = '', $size = 10)
 {
     if ($this->state != 2) {
         return;
     }
     $size /= $this->k;
     $fill = '';
     $bgcolor = $this->bgcolor;
     $color = $this->fgcolor;
     $strokecolor = $this->strokecolor;
     $width = 0;
     $textitem = '';
     $tmpx = $this->x;
     $lspace = $this->GetStringWidth('  ');
     if ($listtype == '^') {
         // special symbol used for avoid justification of rect bullet
         $this->lispacer = '';
         return;
     } elseif ($listtype == '!') {
         // set default list type for unordered list
         $deftypes = array('disc', 'circle', 'square');
         $listtype = $deftypes[($listdepth - 1) % 3];
     } elseif ($listtype == '#') {
         // set default list type for ordered list
         $listtype = 'decimal';
     } elseif (substr($listtype, 0, 4) == 'img|') {
         // custom image type ('img|type|width|height|image.ext')
         $img = explode('|', $listtype);
         $listtype = 'img';
     }
     switch ($listtype) {
         // unordered types
         case 'none':
             break;
         case 'disc':
             $r = $size / 6;
             $lspace += 2 * $r;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $this->Circle($this->x + $r, $this->y + $this->lasth / 2, $r, 0, 360, 'F', array(), $color, 8);
             break;
         case 'circle':
             $r = $size / 6;
             $lspace += 2 * $r;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $prev_line_style = $this->linestyleWidth . ' ' . $this->linestyleCap . ' ' . $this->linestyleJoin . ' ' . $this->linestyleDash . ' ' . $this->DrawColor;
             $new_line_style = array('width' => $r / 3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'phase' => 0, 'color' => $color);
             $this->Circle($this->x + $r, $this->y + $this->lasth / 2, $r * (1 - 1 / 6), 0, 360, 'D', $new_line_style, array(), 8);
             $this->_out($prev_line_style);
             // restore line settings
             break;
         case 'square':
             $l = $size / 3;
             $lspace += $l;
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $this->Rect($this->x, $this->y + ($this->lasth - $l) / 2, $l, $l, 'F', array(), $color);
             break;
         case 'img':
             // 1=>type, 2=>width, 3=>height, 4=>image.ext
             $lspace += $img[2];
             if ($this->rtl) {
                 $this->x += $lspace;
             } else {
                 $this->x -= $lspace;
             }
             $imgtype = strtolower($img[1]);
             $prev_y = $this->y;
             switch ($imgtype) {
                 case 'svg':
                     $this->ImageSVG($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], '', 'T', '', 0, false);
                     break;
                 case 'ai':
                 case 'eps':
                     $this->ImageEps($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], '', true, 'T', '', 0, false);
                     break;
                 default:
                     $this->Image($img[4], $this->x, $this->y + ($this->lasth - $img[3]) / 2, $img[2], $img[3], $img[1], '', 'T', false, 300, '', false, false, 0, false, false, false);
                     break;
             }
             $this->y = $prev_y;
             break;
             // ordered types
             // $this->listcount[$this->listnum];
             // $textitem
         // ordered types
         // $this->listcount[$this->listnum];
         // $textitem
         case '1':
         case 'decimal':
             $textitem = $this->listcount[$this->listnum];
             break;
         case 'decimal-leading-zero':
             $textitem = sprintf('%02d', $this->listcount[$this->listnum]);
             break;
         case 'i':
         case 'lower-roman':
             $textitem = strtolower(TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]));
             break;
         case 'I':
         case 'upper-roman':
             $textitem = TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]);
             break;
         case 'a':
         case 'lower-alpha':
         case 'lower-latin':
             $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
             break;
         case 'A':
         case 'upper-alpha':
         case 'upper-latin':
             $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
             break;
         case 'lower-greek':
             $textitem = TCPDF_FONTS::unichr(945 + $this->listcount[$this->listnum] - 1, $this->isunicode);
             break;
             /*
             // Types to be implemented (special handling)
             case 'hebrew': {
             	break;
             }
             case 'armenian': {
             	break;
             }
             case 'georgian': {
             	break;
             }
             case 'cjk-ideographic': {
             	break;
             }
             case 'hiragana': {
             	break;
             }
             case 'katakana': {
             	break;
             }
             case 'hiragana-iroha': {
             	break;
             }
             case 'katakana-iroha': {
             	break;
             }
             */
         /*
         // Types to be implemented (special handling)
         case 'hebrew': {
         	break;
         }
         case 'armenian': {
         	break;
         }
         case 'georgian': {
         	break;
         }
         case 'cjk-ideographic': {
         	break;
         }
         case 'hiragana': {
         	break;
         }
         case 'katakana': {
         	break;
         }
         case 'hiragana-iroha': {
         	break;
         }
         case 'katakana-iroha': {
         	break;
         }
         */
         default:
             $textitem = $this->listcount[$this->listnum];
     }
     if (!TCPDF_STATIC::empty_string($textitem)) {
         // Check whether we need a new page or new column
         $prev_y = $this->y;
         $h = $this->FontSize * $this->cell_height_ratio + $this->cell_padding['T'] + $this->cell_padding['B'];
         if ($this->checkPageBreak($h) or $this->y < $prev_y) {
             $tmpx = $this->x;
         }
         // print ordered item
         if ($this->rtl) {
             $textitem = '.' . $textitem;
         } else {
             $textitem = $textitem . '.';
         }
         $lspace += $this->GetStringWidth($textitem);
         if ($this->rtl) {
             $this->x += $lspace;
         } else {
             $this->x -= $lspace;
         }
         $this->Write($this->lasth, $textitem, '', false, '', false, 0, false);
     }
     $this->x = $tmpx;
     $this->lispacer = '^';
     // restore colors
     $this->SetFillColorArray($bgcolor);
     $this->SetDrawColorArray($strokecolor);
     $this->SettextColorArray($color);
 }