$BLOCK = strtr($BLOCK, array('_' => '')) . 'BLOCK';
    $content .= "<{$BLOCK}>\n";
    $content .= '  <VERSION>' . $block->version . '</VERSION>' . "\n";
    $content .= '  <POSITION>' . $block_instance->defaultregion . '</POSITION>' . "\n";
    $content .= '  <WEIGHT>' . $block_instance->defaultweight . '</WEIGHT>' . "\n";
    $content .= '  <VISIBLE>1</VISIBLE>' . "\n";
    $content .= '  <CONFIGFIELDS>' . "\n";
    $config = get_object_vars($config);
    foreach ($config as $name => $value) {
        if (empty($name) || is_array($value) || is_object($value)) {
            continue;
            // shouldn't happen !!
        }
        $content .= '    <CONFIGFIELD>' . "\n";
        $content .= '      <NAME>' . xml_tag_safe_content($name) . '</NAME>' . "\n";
        $content .= '      <VALUE>' . xml_tag_safe_content($value) . '</VALUE>' . "\n";
        $content .= '    </CONFIGFIELD>' . "\n";
    }
    $content .= '  </CONFIGFIELDS>' . "\n";
    $content .= "</{$BLOCK}>\n";
}
if (empty($config['title'])) {
    $filename = $block->name . '.xml';
} else {
    $filename = clean_filename(strip_tags(format_string($config['title'], true)) . '.xml');
}
send_file($content, $filename, 0, 0, true, true);
/**
 * xml_tag_safe_content
 *
 * copied from Moodle 1.9 backup/backuplib.php
function full_tag($tag, $level = 0, $endline = true, $content, $attributes = null)
{
    global $CFG;
    //Here we encode absolute links
    // MDL-10770
    if (is_null($content)) {
        $content = '$@NULL@$';
    } else {
        $content = backup_encode_absolute_links($content);
    }
    $st = start_tag($tag, $level, $endline, $attributes);
    $co = xml_tag_safe_content($content);
    $et = end_tag($tag, 0, true);
    return $st . $co . $et;
}
Example #3
0
function full_tag($tag, $level = 0, $endline = true, $content, $attributes = null)
{
    global $CFG;
    //Here we encode absolute links
    $content = backup_encode_absolute_links($content);
    $st = start_tag($tag, $level, $endline, $attributes);
    $co = xml_tag_safe_content($content);
    $et = end_tag($tag, 0, true);
    return $st . $co . $et;
}