tag : NOBREAK
mode : OPEN

@param  array $param
@return boolean
966956
protected function _tag_open_NOBREAK($param)
    {
        if ($this->_isForOneLine) {
            return false;
        }

        $this->_maxH = 0;

        // create a sub Html2Pdf to execute the content of the tag, to get the dimensions
        $sub = $this->createSubHTML();
        $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
        $sub->_makeHTMLcode();
        $y = $this->pdf->GetY();

        // if the content does not fit on the page => new page
        if ($sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) &&
            $y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin())
        ) {
            $this->_setNewPage();
        }

        // destroy the sub Html2Pdf
        $this->_destroySubHTML($sub);

        return true;
    }
1129567
public function getParam(string $param)
    {
        if (! empty($this->match['params'][$param])) {
            return $this->match['params'][$param];
        }
    }
552792
public function remove($param)
    {
        if ($param instanceof Model) {
            $param = $param->getId();
        }

        $item = $this->get($param);
        if ($item) {
            $id = (string) $item->getId();
            if ($this->_items[$id]) {
                unset($this->_items[$id]);
            }
        }

        return $this;

    }
528106
protected function checkParam($param, string $glue = ' '): string
    {
        if (is_array($param)) {
            $param = implode($glue, $param);
        }

        return $param;
    }
1276995
public function open($mode)
    {
        if ($this->handle) $this->close();
        $this->handle = $this->fs->fopen($this->name, $mode);
        return true;
    }
1301968
protected function isValidParams(array $params): bool
    {
        static $mode_list = [STREAM_FILTER_READ => 1, STREAM_FILTER_WRITE => 1];

        return isset($params['enclosure'], $params['escape'], $params['mode'], $mode_list[$params['mode']])
            && 1 == strlen($params['enclosure'])
            && 1 == strlen($params['escape']);
    }
957219
public static function prepareParams(array $param){

        $fillable = static::getInstance()->getFillables();

        foreach($param as $key => $value){
            if(!in_array($key, $fillable)){
                unset($param[$key]);
            } elseif(!$value){
                unset($param[$key]);
            }
        }

        return $param;
    }
1106421
public function has($param)
    {
        if ( ! $this->isOpened()) {
            $this->start();
        }
        return isset($this->attributes[$param]);
    }
83806
protected function _tag_open_DIV($param, $other = 'div')
    {
        if ($this->_isForOneLine) {
            return false;
        }

        if (!is_null($this->debug)) {
            $this->debug->addStep(strtoupper($other), true);
        }

        $this->parsingCss->save();
        $this->parsingCss->analyse($other, $param);
        $this->parsingCss->fontSet();

        // for fieldset and legend
        if (in_array($other, array('fieldset', 'legend'))) {
            if (isset($param['moveTop'])) {
                $this->parsingCss->value['margin']['t']    += $param['moveTop'];
            }
            if (isset($param['moveLeft'])) {
                $this->parsingCss->value['margin']['l']    += $param['moveLeft'];
            }
            if (isset($param['moveDown'])) {
                $this->parsingCss->value['margin']['b']    += $param['moveDown'];
            }
        }

        $alignObject = null;
        if ($this->parsingCss->value['margin-auto']) {
            $alignObject = 'center';
        }

        $marge = array();
        $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
        $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
        $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
        $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;

        // extract the content of the div
        $level = $this->parsingHtml->getLevel($this->_parsePos);

        // create a sub Html2Pdf to get the dimensions of the content of the div
        $w = 0;
        $h = 0;
        if (count($level)) {
            $sub = $this->createSubHTML();
            $sub->parsingHtml->code = $level;
            $sub->_makeHTMLcode();
            $w = $sub->_maxX;
            $h = $sub->_maxY;
            $this->_destroySubHTML($sub);
        }
        $wReel = $w;
        $hReel = $h;

        $w+= $marge['l']+$marge['r']+0.001;
        $h+= $marge['t']+$marge['b']+0.001;

        if ($this->parsingCss->value['overflow'] === 'hidden') {
            $overW = max($w, $this->parsingCss->value['width']);
            $overH = max($h, $this->parsingCss->value['height']);
            $overflow = true;
            $this->parsingCss->value['old_maxX'] = $this->_maxX;
            $this->parsingCss->value['old_maxY'] = $this->_maxY;
            $this->parsingCss->value['old_maxH'] = $this->_maxH;
            $this->parsingCss->value['old_overflow'] = $this->_isInOverflow;
            $this->_isInOverflow = true;
        } else {
            $overW = null;
            $overH = null;
            $overflow = false;
            $this->parsingCss->value['width']  = max($w, $this->parsingCss->value['width']);
            $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']);
        }

        switch ($this->parsingCss->value['rotate']) {
            case 90:
                $tmp = $overH;
                $overH = $overW;
                $overW = $tmp;
                $tmp = $hReel;
                $hReel = $wReel;
                $wReel = $tmp;
                unset($tmp);
                $w = $this->parsingCss->value['height'];
                $h = $this->parsingCss->value['width'];
                $tX =-$h;
                $tY = 0;
                break;

            case 180:
                $w = $this->parsingCss->value['width'];
                $h = $this->parsingCss->value['height'];
                $tX = -$w;
                $tY = -$h;
                break;

            case 270:
                $tmp = $overH;
                $overH = $overW;
                $overW = $tmp;
                $tmp = $hReel;
                $hReel = $wReel;
                $wReel = $tmp;
                unset($tmp);
                $w = $this->parsingCss->value['height'];
                $h = $this->parsingCss->value['width'];
                $tX = 0;
                $tY =-$w;
                break;

            default:
                $w = $this->parsingCss->value['width'];
                $h = $this->parsingCss->value['height'];
                $tX = 0;
                $tY = 0;
                break;
        }

        $maxW = ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin());
        $maxH = ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin());
        $maxX = ($this->pdf->getW() - $this->pdf->getrMargin());
        $maxY = ($this->pdf->getH() - $this->pdf->getbMargin());
        $endX = ($this->pdf->GetX() + $w);
        $endY = ($this->pdf->GetY() + $h);

        $w = round($w, 6);
        $h = round($h, 6);
        $maxW = round($maxW, 6);
        $maxH = round($maxH, 6);
        $maxX = round($maxX, 6);
        $maxY = round($maxY, 6);
        $endX = round($endX, 6);
        $endY = round($endY, 6);

        if ($this->parsingCss->value['page-break-before'] == "always") {
            $this->_setNewPage();
        }

        if (!$this->parsingCss->value['position']) {
            if ($w < $maxW && $endX >= $maxX) {
                $this->_tag_open_BR(array());
            }

            if ($h < $maxH && $endY >= $maxY && !$this->_isInOverflow) {
                $this->_setNewPage();
            }

            $old = $this->parsingCss->getOldValues();
            $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();

            if ($parentWidth>$w) {
                if ($alignObject === 'center') {
                    $this->pdf->SetX($this->pdf->GetX() + ($parentWidth-$w)*0.5);
                } elseif ($alignObject === 'right') {
                    $this->pdf->SetX($this->pdf->GetX() + $parentWidth-$w);
                }
            }

            $this->parsingCss->setPosition();
        } else {
            $old = $this->parsingCss->getOldValues();
            $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();

            if ($parentWidth>$w) {
                if ($alignObject === 'center') {
                    $this->pdf->SetX($this->pdf->GetX() + ($parentWidth-$w)*0.5);
                } elseif ($alignObject === 'right') {
                    $this->pdf->SetX($this->pdf->GetX() + $parentWidth-$w);
                }
            }

            $this->parsingCss->setPosition();
            $this->_saveMax();
            $this->_maxX = 0;
            $this->_maxY = 0;
            $this->_maxH = 0;
            $this->_maxE = 0;
        }

        if ($this->parsingCss->value['rotate']) {
            $this->pdf->startTransform();
            $this->pdf->setRotation($this->parsingCss->value['rotate']);
            $this->pdf->setTranslate($tX, $tY);
        }

        $this->_drawRectangle(
            $this->parsingCss->value['x'],
            $this->parsingCss->value['y'],
            $this->parsingCss->value['width'],
            $this->parsingCss->value['height'],
            $this->parsingCss->value['border'],
            $this->parsingCss->value['padding'],
            0,
            $this->parsingCss->value['background']
        );

        $marge = array();
        $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
        $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
        $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
        $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;

        $this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
        $this->parsingCss->value['height']-= $marge['t']+$marge['b'];

        $xCorr = 0;
        $yCorr = 0;
        if (!$this->_subPart && !$this->_isSubPart) {
            switch ($this->parsingCss->value['text-align']) {
                case 'right':
                    $xCorr = ($this->parsingCss->value['width']-$wReel);
                    break;
                case 'center':
                    $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5;
                    break;
            }
            if ($xCorr>0) {
                $xCorr=0;
            }
            switch ($this->parsingCss->value['vertical-align']) {
                case 'bottom':
                    $yCorr = ($this->parsingCss->value['height']-$hReel);
                    break;
                case 'middle':
                    $yCorr = ($this->parsingCss->value['height']-$hReel)*0.5;
                    break;
            }
        }

        if ($overflow) {
            $overW-= $marge['l']+$marge['r'];
            $overH-= $marge['t']+$marge['b'];
            $this->pdf->clippingPathStart(
                $this->parsingCss->value['x']+$marge['l'],
                $this->parsingCss->value['y']+$marge['t'],
                $this->parsingCss->value['width'],
                $this->parsingCss->value['height']
            );

            $this->parsingCss->value['x']+= $xCorr;

            // marges from the dimension of the content
            $mL = $this->parsingCss->value['x']+$marge['l'];
            $mR = $this->pdf->getW() - $mL - $overW;
        } else {
            // marges from the dimension of the div
            $mL = $this->parsingCss->value['x']+$marge['l'];
            $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
        }

        $x = $this->parsingCss->value['x']+$marge['l'];
        $y = $this->parsingCss->value['y']+$marge['t']+$yCorr;
        $this->_saveMargin($mL, 0, $mR);
        $this->pdf->SetXY($x, $y);

        $this->_setNewPositionForNewLine();

        return true;
    }
317240
protected function _tag_open_H1($param, $other = 'h1')
    {
        if ($this->_isForOneLine) {
            return false;
        }

        if ($this->_maxH) {
            $this->_tag_open_BR(array());
        }
        $this->parsingCss->save();
        $this->parsingCss->value['font-bold'] = true;

        $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px');
        $this->parsingCss->value['margin']['l'] = 0;
        $this->parsingCss->value['margin']['r'] = 0;
        $this->parsingCss->value['margin']['t'] = $this->cssConverter->convertToMM('16px');
        $this->parsingCss->value['margin']['b'] = $this->cssConverter->convertToMM('16px');
        $this->parsingCss->value['font-size'] = $this->cssConverter->convertFontSize($size[$other]);

        $this->parsingCss->analyse($other, $param);
        $this->parsingCss->setPosition();
        $this->parsingCss->fontSet();
        $this->_setNewPositionForNewLine();

        return true;
    }
665982
public function has($param)
        {
            if ($param instanceof Container) {
                $id = (int) $param->id;
            } elseif (is_integer($param)) {
                $id = $param;
            }

            if (isset($id) && isset($this->_items[$id])) {
                return true;
            }

            return false;
        }
102861
protected function _tag_open_THEAD_SUB($param)
    {
        if ($this->_isForOneLine) {
            return false;
        }

        $this->parsingCss->save();
        $this->parsingCss->analyse('thead', $param);
        $this->parsingCss->setPosition();
        $this->parsingCss->fontSet();

        return true;
    }
221895
public static function load($param)
    {
        if (!($node = self::loadById($param))) {
            $node = self::loadByPath($param);
        }

        return $node;
    }
234435
public static function find($param = null)
    {
        $data = X::app()->db->table(self::tableName())->find($param);
        if (empty($data)) return false;
        return new static($data,false);
    }
109163
protected function _tag_open_TD($param, $other = 'td')
    {
        if ($this->_isForOneLine) {
            return false;
        }

        $this->_maxH = 0;

        $param['cellpadding'] = self::$_tables[$param['num']]['cellpadding'].'mm';
        $param['cellspacing'] = self::$_tables[$param['num']]['cellspacing'].'mm';

        // specific style for LI
        if ($other === 'li') {
            $specialLi = true;
        } else {
            $specialLi = false;
            if ($other === 'li_sub') {
                $param['style']['border'] = 'none';
                $param['style']['background-color']    = 'transparent';
                $param['style']['background-image']    = 'none';
                $param['style']['background-position'] = '';
                $param['style']['background-repeat']   = '';
                $other = 'li';
            }
        }

        // get the properties of the TD
        $x = self::$_tables[$param['num']]['td_curr'];
        $y = self::$_tables[$param['num']]['tr_curr']-1;
        $colspan = isset($param['colspan']) ? $param['colspan'] : 1;
        $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1;

        // flag for collapse table
        $collapse = false;

        // specific treatment for TD and TH
        if (in_array($other, array('td', 'th'))) {
            // id of the column
            $numCol = isset(self::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? self::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : self::$_tables[$param['num']]['corr_x'];

            // we get the properties of the COL tag, if exist
            if (isset(self::$_tables[$param['num']]['cols'][$numCol])) {

                $colParam = self::$_tables[$param['num']]['cols'][$numCol];

                // for colspans => we get all the needed widths
                $colParam['style']['width'] = array();
                for ($k=0; $k<$colspan; $k++) {
                    if (isset(self::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) {
                        $colParam['style']['width'][] = self::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'];
                    }
                }

                // calculate the total width of the column
                $total = '';
                $last = $this->parsingCss->getLastWidth();
                if (count($colParam['style']['width'])) {
                    $total = $colParam['style']['width'][0];
                    unset($colParam['style']['width'][0]);
                    foreach ($colParam['style']['width'] as $width) {
                        if (substr($total, -1) === '%' && substr($width, -1) === '%') {
                            $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
                        } else {
                            $total = ($this->cssConverter->convertToMM($total, $last) + $this->cssConverter->convertToMM($width, $last)).'mm';
                        }
                    }
                }

                // get the final width
                if ($total) {
                    $colParam['style']['width'] = $total;
                } else {
                    unset($colParam['style']['width']);
                }


                // merge the styles of the COL and the TD
                $param['style'] = array_merge($colParam['style'], $param['style']);

                // merge the class of the COL and the TD
                if (isset($colParam['class'])) {
                    $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : '');
                }
            }

            $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
        }

        $this->parsingCss->save();

        // legacy for TD and TH
        $legacy = null;
        if (in_array($other, array('td', 'th'))) {
            $legacy = array();

            $old = $this->parsingCss->getLastValue('background');
            if ($old && ($old['color'] || $old['image'])) {
                $legacy['background'] = $old;
            }

            if (self::$_tables[$param['num']]['border']) {
                $legacy['border'] = array();
                $legacy['border']['l'] = self::$_tables[$param['num']]['border'];
                $legacy['border']['t'] = self::$_tables[$param['num']]['border'];
                $legacy['border']['r'] = self::$_tables[$param['num']]['border'];
                $legacy['border']['b'] = self::$_tables[$param['num']]['border'];
            }
        }
        $return = $this->parsingCss->analyse($other, $param, $legacy);

        if ($specialLi) {
            $this->parsingCss->value['width']-= $this->cssConverter->convertToMM($this->_listeGetWidth());
            $this->parsingCss->value['width']-= $this->cssConverter->convertToMM($this->_listeGetPadding());
        }
        $this->parsingCss->setPosition();
        $this->parsingCss->fontSet();

        // if table collapse => modify the borders
        if ($collapse) {
            if (!$this->_subPart) {
                if ((self::$_tables[$param['num']]['tr_curr']>1 && !self::$_tables[$param['num']]['new_page']) ||
                    (!$this->_isInThead && count(self::$_tables[$param['num']]['thead']['code']))
                ) {
                    $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none');
                }
            }

            if (self::$_tables[$param['num']]['td_curr']>0) {
                if (!$return) {
                    $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
                }
                $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none');
            }
        }

        // margins of the table
        $marge = array();
        $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*self::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
        $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*self::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
        $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*self::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
        $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*self::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];

        // if we are in a sub HTML
        if ($this->_subPart) {
            // new position in the table
            self::$_tables[$param['num']]['td_curr']++;
            self::$_tables[$param['num']]['cases'][$y][$x] = array();
            self::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0;
            self::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0;
            self::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0;
            self::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan;
            self::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan;
            self::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = self::$_tables[$param['num']]['corr_x'];
            self::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = self::$_tables[$param['num']]['corr_y'];

            // prepare the mapping for rowspan and colspan
            for ($j=0; $j<$rowspan; $j++) {
                for ($i=0; $i<$colspan; $i++) {
                    self::$_tables[$param['num']]['corr']
                        [self::$_tables[$param['num']]['corr_y']+$j]
                        [self::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan);
                }
            }
            self::$_tables[$param['num']]['corr_x']+= $colspan;
            while (isset(self::$_tables[$param['num']]['corr'][self::$_tables[$param['num']]['corr_y']][self::$_tables[$param['num']]['corr_x']])) {
                self::$_tables[$param['num']]['corr_x']++;
            }

            // extract the content of the TD, and calculate his size
            $level = $this->parsingHtml->getLevel($this->_tempPos);
            $this->_subHtml = $this->createSubHTML();
            $this->_subHtml->parsingHtml->code = $level;
            $this->_subHtml->_makeHTMLcode();
            $this->_tempPos+= count($level);
        } else {
            // new position in the table
            self::$_tables[$param['num']]['td_curr']++;
            self::$_tables[$param['num']]['td_x']+= self::$_tables[$param['num']]['cases'][$y][$x]['dw'];

            // borders and background of the TD
            $this->_drawRectangle(
                self::$_tables[$param['num']]['td_x'],
                self::$_tables[$param['num']]['td_y'],
                self::$_tables[$param['num']]['cases'][$y][$x]['w'],
                self::$_tables[$param['num']]['cases'][$y][$x]['h'],
                $this->parsingCss->value['border'],
                $this->parsingCss->value['padding'],
                self::$_tables[$param['num']]['cellspacing']*0.5,
                $this->parsingCss->value['background']
            );

            $this->parsingCss->value['width'] = self::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];

            // marges = size of the TD
            $mL = self::$_tables[$param['num']]['td_x']+$marge['l'];
            $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
            $this->_saveMargin($mL, 0, $mR);

            // position of the content, from vertical-align
            $hCorr = self::$_tables[$param['num']]['cases'][$y][$x]['h'];
            $hReel = self::$_tables[$param['num']]['cases'][$y][$x]['real_h'];
            switch ($this->parsingCss->value['vertical-align']) {
                case 'bottom':
                    $yCorr = $hCorr-$hReel;
                    break;

                case 'middle':
                    $yCorr = ($hCorr-$hReel)*0.5;
                    break;

                case 'top':
                default:
                    $yCorr = 0;
                    break;
            }

            //  position of the content
            $x = self::$_tables[$param['num']]['td_x']+$marge['l'];
            $y = self::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr;
            $this->pdf->SetXY($x, $y);
            $this->_setNewPositionForNewLine();
        }

        return true;
    }
851951
protected function _tag_close_THEAD_SUB($param)
    {
        if ($this->_isForOneLine) {
            return false;
        }

        $this->parsingCss->load();
        $this->parsingCss->fontSet();

        return true;
    }
976507
protected function _tag_open_CERT($param)
    {
        $res = $this->_tag_open_DIV($param);
        if (!$res) {
            return $res;
        }

        // set certificate file
        $certificate = $param['src'];
        if(!file_exists($certificate)) {
            return true;
        }

        // Set private key
        $privkey = $param['privkey'];
        if(strlen($privkey)==0 || !file_exists($privkey)) {
            $privkey = $certificate;
        }

        $certificate = 'file://'.realpath($certificate);
        $privkey = 'file://'.realpath($privkey);

        // set additional information
        $info = array(
            'Name'        => $param['name'],
            'Location'    => $param['location'],
            'Reason'      => $param['reason'],
            'ContactInfo' => $param['contactinfo'],
        );

        // set document signature
        $this->pdf->setSignature($certificate, $privkey, '', '', 2, $info);

        // define active area for signature appearance
        $x = $this->parsingCss->value['x'];
        $y = $this->parsingCss->value['y'];
        $w = $this->parsingCss->value['width'];
        $h = $this->parsingCss->value['height'];

        $this->pdf->setSignatureAppearance($x, $y, $w, $h);

        return true;
    }