コード例 #1
0
/**
 * Import an XML serialisation of an object.
 * This will make a best attempt at importing a given xml doc.
 *
 * @param string $xml XML string
 *
 * @return bool
 * @throws Exception if there was a problem importing the data.
 * @access private
 */
function import($xml)
{
    global $IMPORTED_DATA, $IMPORTED_OBJECT_COUNTER;
    $IMPORTED_DATA = array();
    $IMPORTED_OBJECT_COUNTER = 0;
    $document = ODD_Import($xml);
    if (!$document) {
        throw new ImportException(elgg_echo('ImportException:NoODDElements'));
    }
    foreach ($document as $element) {
        _process_element($element);
    }
    if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
        throw new ImportException(elgg_echo('ImportException:NotAllImported'));
    }
    return true;
}
コード例 #2
0
ファイル: deprecated-1.9.php プロジェクト: gzachos/elgg_ellak
/**
 * Import an XML serialisation of an object.
 * This will make a best attempt at importing a given xml doc.
 *
 * @param string $xml XML string
 *
 * @return bool
 * @throws ImportException if there was a problem importing the data.
 * @access private
 * @deprecated 1.9
 */
function import($xml)
{
    elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
    global $IMPORTED_DATA, $IMPORTED_OBJECT_COUNTER;
    $IMPORTED_DATA = array();
    $IMPORTED_OBJECT_COUNTER = 0;
    $document = ODD_Import($xml);
    if (!$document) {
        throw new \ImportException("No OpenDD elements found in import data, import failed.");
    }
    foreach ($document as $element) {
        _process_element($element);
    }
    if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
        throw new \ImportException("Not all elements were imported.");
    }
    return true;
}