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0Ni[x(¦:_O	7\f#f
 ,Y Q1/M樽Hc	,aܜh=irm˩heeDӫ8E:2TbBld6xygA,$u8MX]忯nͯa,9 ;O.nuBU\DiiL_0US%Vx%P7C{6t6(tb-rH\98lS֙^KYr-g<B~8P/Gvs#u|=K4$\B84:@ܡp1Uԕ/-Ks1*<P+hU'x+R2.kOѣ,cMkZE;Y֍&zw$dQ-)|'CŶq@:Y=f yq^_!Iu	FyzLC6qc~0d J1~wI#J~Yr}ᕅIhvEY%s&Ans5fzw$dQ-36v(s,HCCXI޺d-ڝsHZ;~Y#7Wu;*	?k&=TLzbxS+yVTS$.fGȟ!ִ~4v	;7u+?˹V/ J0(zژɺ:0S[{q|ܣNaG-=CktKќ}ZP>W(r-vC"Yz:4xtZvC]yB|_=eiuL(@mXedS)mUX|%PSf{NjDKkLBRhdtʲgz٥<St _;(SCu-,2g^	Lz|=1pq$_>ᙢG1ٙaay!+WH{P}k!eHZТ]l(I_BW`r3-kL.=!s;^0XLvZ i(<-XMLmr/>F$P~\k`:L]Y;f}%iE@ ǌ4(kFIŭq E֕^\M~N}8`pzd;$.h8:2e+rɰ#;`QAfゅs&yxD?ۊKoq*XHXދ d|a0RrBaqW[Լ#BLZWW4|<~ ~$۞&/{$Ӹ֖ka#[+3rhnCw/0Q[Kpci+8.>#N|s242ƫba Ox)A9;~F`'þ*egWVt.5BE(S@i/1gg7E߶iH\kf]/Q$[+Q(8
oa ϔ
viyÓb̮:*P{VͼZ
0IxdSWnW=bql%:䐔ĆdrӥK׾dm[xijg0R9&CfI	$K>
SqkT'DvJ<I :(sL: JS̋Y_vjY"v+2V,%ʹi.AVÒqgF4) {
        $output .= '<input type="hidden" name="rownumber" value="'
            . htmlspecialchars($_REQUEST['rownumber']) . '" />';
    }
    $filter_value = (isset($_REQUEST['foreign_filter'])
        ? htmlspecialchars($_REQUEST['foreign_filter'])
        : '');
    $output .= '<span class="formelement">'
        . '<label for="input_foreign_filter">' . __('Search:') . '</label>'
        . '<input type="text" name="foreign_filter" '
        . 'id="input_foreign_filter" '
        . 'value="' . $filter_value . '" data-old="' . $filter_value . '" '
        . '/>'
        . '<input type="submit" name="submit_foreign_filter" value="'
        .  __('Go') . '" />'
        . '</span>'
        . '<span class="formelement">' . $gotopage . '</span>'
        . '<span class="formelement">' . $showall . '</span>'
        . '</fieldset>'
        . '</form>';

    $output .= '<table width="100%" id="browse_foreign_table">';

    if (!is_array($foreignData['disp_row'])) {
        $output .= '</tbody>'
            . '</table>';

        return $output;
    }

    $header = '<tr>
        <th>' . __('Keyname') . '</th>
        <th>' . __('Description') . '</th>
        <td width="20%"></td>
        <th>' . __('Description') . '</th>
        <th>' . __('Keyname') . '</th>
    </tr>';

    $output .= '<thead>' . $header . '</thead>' . "\n"
        . '<tfoot>' . $header . '</tfoot>' . "\n"
        . '<tbody>' . "\n";

    $descriptions = array();
    $keys   = array();
    foreach ($foreignData['disp_row'] as $relrow) {
        if ($foreignData['foreign_display'] != false) {
            $descriptions[] = $relrow[$foreignData['foreign_display']];
        } else {
            $descriptions[] = '';
        }

        $keys[] = $relrow[$foreignData['foreign_field']];
    }

    asort($keys);

    $horizontal_count = 0;
    $odd_row = true;
    $indexByDescription = 0;

    foreach ($keys as $indexByKeyname => $value) {
        list(
            $html,
            $horizontal_count,
            $odd_row,
            $indexByDescription
        ) = PMA_getHtmlForOneKey(
            $horizontal_count, $header, $odd_row, $keys, $indexByKeyname,
            $descriptions, $indexByDescription, $current_value
        );
        $output .= $html;
    }

    $output .= '</tbody>'
        . '</table>';

    return $output;
}

/**
 * Get the description (possibly truncated) and the title
 *
 * @param string $description the key name's description
 *
 * @return array the new description and title
 */
function PMA_getDescriptionAndTitle($description)
{
    $limitChars = $GLOBALS['cfg']['LimitChars'];
    if (mb_strlen($description) <= $limitChars) {
        $description = htmlspecialchars(
            $description
        );
        $descriptionTitle = '';
    } else {
        $descriptionTitle = htmlspecialchars(
            $description
        );
        $description = htmlspecialchars(
            mb_substr(
                $description, 0, $limitChars
            )
            . '...'
        );
    }
    return array($description, $descriptionTitle);
}

/**
 * Function to get html for each column element
 *
 * @param string $cssClass    class="nowrap" or ''
 * @param bool   $isSelected  whether current equals form's value
 * @param string $keyname     current key
 * @param string $description current value
 * @param string $title       current title
 *
 * @return string
 */
function PMA_getHtmlForColumnElement($cssClass, $isSelected, $keyname,
    $description, $title
) {
    $keyname = htmlspecialchars($keyname);
    $output = '<td';
    if (! empty($cssClass)) {
        $output .= ' ' . $cssClass;
    }
    $output .= '>'
        . ($isSelected ? '<strong>' : '')
        . '<a class="foreign_value" data-key="' . $keyname . '" '
        . 'href="#" title="' . __('Use this value')
        . ($title != ''
            ? ': ' . $title
            : '')
        . '">';
    if ($cssClass !== '') {
        $output .= $keyname;
    } else {
        $output .= $description;
    }

    $output .=  '</a>' . ($isSelected ? '</strong>' : '') . '</td>';

    return $output;
}

/**
 * Function to get html for show all case
 *
 * @param array $foreignData foreign data
 *
 * @return string
 */
function PMA_getHtmlForShowAll($foreignData)
{
    $showall = '';
    if (is_array($foreignData['disp_row'])) {
        if ($GLOBALS['cfg']['ShowAll']
            && ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows'])
        ) {
            $showall = '<input type="submit" id="foreign_showAll" '
                . 'name="foreign_showAll" '
                . 'value="' . __('Show all') . '" />';
        }
    }

    return $showall;
}

/**
 * Function to get html for the goto page option
 *
 * @param array $foreignData foreign data
 *
 * @return string
 */
function PMA_getHtmlForGotoPage($foreignData)
{
    $gotopage = '';
    isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
    if (!is_array($foreignData['disp_row'])) {
        return $gotopage;
    }

    $session_max_rows = $GLOBALS['cfg']['MaxRows'];
    $pageNow = @floor($pos / $session_max_rows) + 1;
    $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);

    if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
        $gotopage = PMA\libraries\Util::pageselector(
            'pos',
            $session_max_rows,
            $pageNow,
            $nbTotalPage,
            200,
            5,
            5,
            20,
            10,
            __('Page number:')
        );
    }

    return $gotopage;
}

/**
 * Function to get foreign limit
 *
 * @param string $foreign_showAll foreign navigation
 *
 * @return string
 */
function PMA_getForeignLimit($foreign_showAll)
{
    if (isset($foreign_showAll) && $foreign_showAll == __('Show all')) {
        return null;
    }
    isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
    return 'LIMIT ' . $pos . ', ' . intval($GLOBALS['cfg']['MaxRows']) . ' ';
}
