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{X&WwCb*)rך=fؽ㏛_薚ghL,نy+]>ܸ[ьڦ̙Ԝiˎg(-vAÕGDP{}(nV@LHvU(@-3Аe 릭4ڟ{uZ	?)C畍TL1hId#̫__>&.e 릭4ڟ{ul 3C1`"i}t޳h(E^yZ;SDxt2.؇s`Xy-=`aA)]?δ̥kP. ^ڜ<a1!RNoGno_4Z밺zD~Ka2@i2kڦjM8^'SHz+ˣ ^KLݛDve6A\~!gwB+F,6B&&,D;Z6 4XҮ7B=hRq7\3?OD̪nX%!4ܗI%b2H6bdB/(S{8/55fƹOo6]/%n]cنy+]>`CT:SY22}`xhE勿F	3Nᾣ1#ɎzHE!kcppəxdp65`gqgYǥ8ߤRݵ[N%_vR3Nᾣ1#Ɏz^c坦</(S{mxJryv\GwL^NA7hK+Ca,K7I?zfǵ+F,6B&&,D; ^NȵWa$F0j%PG/-]!-z3881D/;8د^&|A$_ :5{H^(DE~n,H'EVԞ]	X,J>nx :+HXik%Bܻ%e@3+=.GR,1Rm c
?ScYי[dRtv(ʷxs_qYz^46L.`&v8xs\VP'dv{g>zVk?\"*NM-Vlv9AȾ826lʯczo'b\& v1~?࢛+AWE2fjbdBNNݑ]2|t98kgF@
~7aF?Hd!,D2.suJa8?EiPvNϟڽeJt5n)m*ح<,<fyEg[hOU<IfV+>7r>R_+IR28}lF
4	,SdCd(Ԅr9.LHrwݘ6Fب=ԎKJ^Δ:`.Ϯތ!w>ݿ`rs-Y<Ӏ`$_?59
#B{vLJ~Ph,93Nᾣ1#Ɏzs9Dcm/YE禡<K)I&
An=M<Ahc*jާUvL-eXansTK`:b7p{mu^,"MiѼ%D,*|8`32vFܾ)hr%ݹKOD<BC0)xKuGdF
ylKǾ$ Y̡'C}k-1)            if (in_array($rel['foreign_table'], $alltables)) {
                        $this->_addRelation(
                            $one_table,
                            $this->diagram->getFont(),
                            $this->diagram->getFontSize(),
                            $master_field,
                            $rel['foreign_table'],
                            $rel['foreign_field'],
                            $this->tableDimension
                        );
                    }
                    continue;
                }

                foreach ($rel as $one_key) {
                    if (!in_array($one_key['ref_table_name'], $alltables)) {
                        continue;
                    }

                    foreach (
                        $one_key['index_list']
                        as $index => $one_field
                    ) {
                        $this->_addRelation(
                            $one_table,
                            $this->diagram->getFont(),
                            $this->diagram->getFontSize(),
                            $one_field,
                            $one_key['ref_table_name'],
                            $one_key['ref_index_list'][$index],
                            $this->tableDimension
                        );
                    }
                }
            }
        }
        if ($seen_a_relation) {
            $this->_drawRelations();
        }

        $this->_drawTables();
        $this->diagram->endSvgDoc();
    }

    /**
     * Output RelationStatsSvg Document for download
     *
     * @return void
     */
    public function showOutput()
    {
        $this->diagram->showOutput($this->getFileName('.svg'));
    }

    /**
     * Sets X and Y minimum and maximum for a table cell
     *
     * @param string $table The table name
     *
     * @return void
     */
    private function _setMinMax($table)
    {
        $this->_xMax = max($this->_xMax, $table->x + $table->width);
        $this->_yMax = max($this->_yMax, $table->y + $table->height);
        $this->_xMin = min($this->_xMin, $table->x);
        $this->_yMin = min($this->_yMin, $table->y);
    }

    /**
     * Defines relation objects
     *
     * @param string  $masterTable    The master table name
     * @param string  $font           The font face
     * @param int     $fontSize       Font size
     * @param string  $masterField    The relation field in the master table
     * @param string  $foreignTable   The foreign table name
     * @param string  $foreignField   The relation field in the foreign table
     * @param boolean $tableDimension Whether to display table position or not
     *
     * @return void
     *
     * @see _setMinMax,Table_Stats_Svg::__construct(),
     *       PMA\libraries\plugins\schema\svg\RelationStatsSvg::__construct()
     */
    private function _addRelation(
        $masterTable,
        $font,
        $fontSize,
        $masterField,
        $foreignTable,
        $foreignField,
        $tableDimension
    ) {
        if (!isset($this->_tables[$masterTable])) {
            $this->_tables[$masterTable] = new TableStatsSvg(
                $this->diagram, $this->db,
                $masterTable, $font, $fontSize, $this->pageNumber,
                $this->_tablewidth, false, $tableDimension
            );
            $this->_setMinMax($this->_tables[$masterTable]);
        }
        if (!isset($this->_tables[$foreignTable])) {
            $this->_tables[$foreignTable] = new TableStatsSvg(
                $this->diagram, $this->db,
                $foreignTable, $font, $fontSize, $this->pageNumber,
                $this->_tablewidth, false, $tableDimension
            );
            $this->_setMinMax($this->_tables[$foreignTable]);
        }
        $this->_relations[] = new RelationStatsSvg(
            $this->diagram,
            $this->_tables[$masterTable],
            $masterField,
            $this->_tables[$foreignTable],
            $foreignField
        );
    }

    /**
     * Draws relation arrows and lines
     * connects master table's master field to
     * foreign table's foreign field
     *
     * @return void
     *
     * @see Relation_Stats_Svg::relationDraw()
     */
    private function _drawRelations()
    {
        foreach ($this->_relations as $relation) {
            $relation->relationDraw($this->showColor);
        }
    }

    /**
     * Draws tables
     *
     * @return void
     *
     * @see Table_Stats_Svg::Table_Stats_tableDraw()
     */
    private function _drawTables()
    {
        foreach ($this->_tables as $table) {
            $table->tableDraw($this->showColor);
        }
    }
}
