コード例 #1
0
/**
 * Generates all of the test data and field/column definitions that will
 * make up the data and metadata for this request.
 */
function generateData()
{
    global $date_format;
    $row_count = rand(10, 30);
    $col_count = rand(3, 7);
    $types = array();
    $data['data'] = array();
    $fields = array();
    $columns = array();
    $defineFields = true;
    for ($i = 0; $i < $row_count; $i++) {
        for ($j = 0; $j < $col_count; $j++) {
            // first pass through columns only, define fields and columns
            if ($defineFields) {
                // generate a random data type for the field/column
                $type = generateType($j);
                array_push($types, $type);
                // =====================================================================
                // define the default placeholder field definition. this fields
                // config is supported by the metachange handling in Ext by default
                // to reconfigure the data store's field definitions.
                $field = array('name' => 'field-' . ($j + 1), 'type' => $type['data']);
                // add any type-specific field attributes
                if ($type['data'] === 'date') {
                    $field['dateFormat'] = $date_format;
                }
                // add the field to the fields list
                array_push($fields, $field);
                // =====================================================================
                // define the default placeholder column definition to match the field.
                // note that this columns block only applies to grids. in the past the
                // fields config was reused both by the store and also by grids, but since
                // it is usually preferable to add column-specific metadata that the store
                // doesn't care about, it's usually better to split the two definitions.
                $col = array('dataIndex' => 'field-' . ($j + 1));
                // add in column-specific attributes
                if ($j === 0) {
                    // special config for the id column, fixed width and non-editable
                    $col['text'] = 'ID';
                    $col['width'] = 40;
                } else {
                    $col['text'] = 'Field ' . ($j + 1) . ' (' . $type['data'] . ')';
                    $col['editor'] = $type['editor'];
                    $col['flex'] = 1;
                }
                // add in type-specific column attributes
                switch ($type['data']) {
                    case 'date':
                        $col['xtype'] = 'datecolumn';
                        $col['format'] = $date_format;
                        break;
                    case 'float':
                        $col['xtype'] = 'numbercolumn';
                        $col['format'] = '$0.00';
                        break;
                    case 'bool':
                        //$col['xtype'] = 'checkcolumn';
                        break;
                }
                // finally, add the column to the columns list
                array_push($columns, $col);
            }
            // every row/col pass, load up some data
            $row['field-' . ($j + 1)] = $j == 0 ? $i + 1 : getDataValue($types[$j]);
        }
        // flip this flag after the first column pass since the fields are defined
        $defineFields = false;
        // add the row of generated data to the top-level data object
        // that will be returned in the response
        array_push($data['data'], $row);
    }
    // assemble the metadata
    $meta = array();
    $meta['fields'] = $fields;
    $meta['columns'] = $columns;
    $meta['root'] = 'data';
    $meta['idProperty'] = 'field-1';
    $meta['messageProperty'] = 'msg';
    // assemble the top-level data object being returned.
    // the data is already in $data['data'] at this point.
    $data['metaData'] = $meta;
    $data['total'] = $row_count;
    $data['msg'] = 'Success!';
    return $data;
}
コード例 #2
0
ファイル: default.php プロジェクト: NovuForum/NovuForum
<?php

require "../includes/config.php";
foreach (scandir("../includes/functions") as $value) {
    if ($value == "." || $value == "..") {
        continue;
    }
    include "functions/{$value}";
}
// Global Variables
$URL = $_SERVER['QUERY_STRING'];
$URL_SPLIT = explode('/', $URL);
$textonly = $URL_SPLIT[0] == "json" ? true : false;
$loginrequired = (bool) getDataValue("loginrequired");
$loginrequired = $loginrequired != false ? true : false;
$parser = array();
// Dynamic Variables
if (!$textonly) {
    $theme = getActiveTheme();
}
if ($URL_SPLIT[0] == "forum" && is_numeric($URL_SPLIT[1])) {
    $forumid = $URL_SPLIT[1];
}
include "pagehandler.php";
// Libraries
include "libraries/Parsedown.php";
// Parser Variables