コード例 #1
0
ファイル: export.php プロジェクト: smcaleer/scriptmind-links
function exportTable($db, $table, $sql, $entityName, $translations, $subqueries = '', $indent = "\t", $idField = "ID")
{
    global $tables, $tablesToProcess;
    unset($tablesToProcess[$table]);
    $rs = $db->Execute($sql);
    if (!$rs) {
        return false;
    }
    $noSubquery = !is_array($subqueries);
    while (!$rs->EOF) {
        $fields = $rs->fields;
        $id = $rs->Fields($idField);
        $rs->MoveNext();
        $entity = $indent . "<{$entityName} ID=\"{$id}\"";
        $inner = array();
        foreach ($fields as $key => $value) {
            if ($key == $idField) {
                continue;
            }
            if (empty($translations[$key])) {
                if (empty($value)) {
                    continue;
                }
            } else {
                $translate = $translations[$key];
                if (!empty($translate['ignore'])) {
                    continue;
                }
                if (empty($value) && empty($translate['includeEmpty'])) {
                    continue;
                }
                if (!empty($translate['name'])) {
                    $key = $translate['name'];
                }
                if (!empty($translate['cdata'])) {
                    $inner[] = array($key => '<![CDATA[' . $value . ']]>');
                    continue;
                }
                $value = xml_utf8_encode($value);
                if (!empty($translate['inner'])) {
                    $inner[] = array($key => $value);
                    continue;
                }
            }
            $entity .= " {$key}=\"{$value}\"";
        }
        if ($noSubquery && empty($inner)) {
            print $entity . "/>\n";
        } else {
            print $entity . ">\n";
            foreach ($inner as $values) {
                foreach ($values as $key => $value) {
                    print "{$indent}\t<{$key}>{$value}</{$key}>\n";
                }
            }
            if (!$noSubquery) {
                foreach ($subqueries as $subquery) {
                    $subtable = $tables[$subquery['table']]['name'];
                    $linkField = $subquery['link'];
                    $subsql = "SELECT * FROM `{$subtable}` WHERE `{$linkField}` = {$id} ORDER BY ID";
                    if (empty($subquery['translation'])) {
                        $omit = array();
                    } else {
                        $omit = $subquery['translation'];
                    }
                    if (empty($omit[$linkField])) {
                        $omit[$linkField] = array('ignore' => 1);
                    }
                    exportTable($db, $subquery['table'], $subsql, $subquery['entity'], $omit, '', $indent . "\t");
                }
            }
            print "{$indent}</{$entityName}>\n";
        }
    }
    return true;
}
コード例 #2
0
ファイル: Export.php プロジェクト: Krinkle/xtools
*/
/**
 * Improvements by Igor Blanco at Binovo IT Human Project 
 *  Url: http://www.binovo.es
 *  
 *  - saveOds and parseOds now uses Zip clases instead of temporary directory
 *  - now formulas can be added to the cells
 *  - some simple methods to translate to and from zero based column and row numbers
 *  to the right names for the formulas.
 */
require_once '/data/project/xtools/modules/WebTool.php';
require_once 'ArticleInfo.php';
$wt = new WebTool('export');
$hash = $wgRequest->getVal('token');
if ($hash) {
    exportTable($hash);
} else {
    echo "no hash";
}
function exportTable($hash)
{
    global $redis, $wt, $I18N, $perflog;
    $lc = $redis->get("xtoolsAI" . $hash);
    if ($lc === false) {
        echo "Key is expired. Please reload page history.";
        exit(0);
    } else {
        $ai = unserialize($lc);
        #		unset( $lc );
        #		print_r($ai);
    }