0

当我注意到有一些不寻常的 PHPBB 框架代码与 PHP 的其余部分随机放入时,我一直在摆弄第三方脚本。我需要了解的是,如果这段代码有什么特别之处(它可以做一些普通 PHP 做不到的事情吗?),如果代码没有什么特别之处,我如何在没有框架的情况下顺利地将代码转换为 PHP .

<?
include('bar.php');
include "../includes/config.inc.php";
include "loggedin.inc.php";
include "../includes/countries.inc.php";
$auction_id = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : "";
?>
<?
define("DATAGRID_DIR", "../datagrid/");
define("PEAR_DIR", "../datagrid/pear/");
require_once(DATAGRID_DIR . 'datagrid.class.php');
require_once(PEAR_DIR . 'PEAR.php');
require_once(PEAR_DIR . 'DB.php');
$DB_USER = $DbUser;
$DB_PASS = $DbPassword;
$DB_HOST = $DbHost;
$DB_NAME = $DbDatabase;
ob_start();
$db_conn     = DB::factory('mysql');
$result_conn = $db_conn->connect(DB::parseDSN('mysql://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME));
if (DB::isError($result_conn)) {
    die($result_conn->getDebugInfo());
}
$sql = "SELECT u.id, u.nick, COUNT(b.bidder) AS bid_count, 'View offers' AS link
            FROM BPLA_bids b
                INNER JOIN BPLA_users u ON b.bidder=u.id
            WHERE b.auction=$auction_id
            GROUP BY b.bidder";
$unique_prefix       = "au_";
$dgrid               = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
$default_order_field = "nick";
$default_order_type  = "ASC";
$dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);
$dg_language = "en";
$dgrid->setInterfaceLang($dg_language);
$direction = "ltr";
$dgrid->setDirection($direction);
$modes = array(
    "add" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "edit" => array(
        "view" => false,
        "edit" => false,
        "type" => "link",
        "byFieldValue" => ""
    ),
    "cancel" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "details" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "delete" => array(
        "view" => false,
        "edit" => false,
        "type" => "image"
    )
);
$dgrid->setModes($modes);
$http_get_vars = array(
    "aid"
);
$dgrid->setHttpGetVars($http_get_vars);
$printing_option = false;
$dgrid->allowPrinting($printing_option);
$exporting_option    = false;
$exporting_directory = "";
$dgrid->allowExporting($exporting_option, $exporting_directory);
$sorting_option = true;
$dgrid->allowSorting($sorting_option);
$paging_option   = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);
$bottom_paging     = array();
$top_paging        = array();
$pages_array       = array(
    "10" => "10",
    "25" => "25",
    "50" => "50",
    "100" => "100",
    "250" => "250"
);
$default_page_size = 10;
$paging_arrows     = array(
    "first" => "|&lt;&lt;",
    "previous" => "&lt;&lt;",
    "next" => "&gt;&gt;",
    "last" => "&gt;&gt;|"
);
$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
$dgrid->setViewModeTableProperties($vm_table_properties);
$vm_colimns = array(
    "nick" => array(
        "header" => "Nick",
        "type" => "label",
        "summarize" => "false",
        "visible" => "true"
    ),
    "bid_count" => array(
        "header" => "Bid count",
        "type" => "label",
        "summarize" => "false",
        "visible" => "true"
    ),
    "link" => array(
        "header" => "&nbsp;",
        "type" => "link",
        "field_key" => "id",
        "field_data" => "link",
        "href" => "auction_users_bids.php?aid=$auction_id&uid={0}"
    )
);
$dgrid->setColumnsInViewMode($vm_colimns);
$dgrid->bind();
ob_end_flush();   
?>
4

1 回答 1

1

PHPBB 使用标准的 PHP 代码。在您显示的代码中,使用了 PHPBB 之前定义的 DataGrid 类。如果您可以找到该类的定义位置,则可能有助于理解它在做什么。搜索

class DataGrid

在 PHPBB 代码中了解有关该类的更多信息。

于 2012-11-04T05:03:23.797 回答