function get_category_content(&$xmlElement, &$resources, $id, $name, $exportpath, $export_dir, $identifier, &$ridentifier, $viewid)
{
    global $USER, $CFG, $COURSE;
    $bookmarks = get_category_items($id, $viewid, 'link');
    $hasItems = false;
    if ($bookmarks) {
        $hasItems = true;
        foreach ($bookmarks as $bookmark) {
            unset($filecontent);
            unset($filename);
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch(format_string($bookmark->name)) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch(format_string($bookmark->name)) . '</h1>' . "\n";
            $filecontent .= '  <div id="url"><a href="' . spch($bookmark->url) . '"><!--###BOOKMARK_EXT_URL###-->' . spch($bookmark->url) . '<!--###BOOKMARK_EXT_URL###--></a></div>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_EXT_DESC###-->' . spch_text($bookmark->intro) . '<!--###BOOKMARK_EXT_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $bookmark->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($bookmark->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $bookmark->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    $files = get_category_items($id, $viewid, 'file');
    if ($files) {
        $hasItems = true;
        foreach ($files as $file) {
            unset($filecontent);
            unset($filename);
            $i = 0;
            $content_filename = $file->attachment;
            if (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename)) {
                do {
                    $i++;
                    $content_filename = $i . $file->attachment;
                } while (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename));
            }
            if ($file->attachment != '') {
                copy($CFG->dataroot . "/" . block_exabis_eportfolio_file_area_name($file) . "/" . $file->attachment, $exportpath . $export_dir . $content_filename);
            }
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch($file->name) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch($file->name) . '</h1>' . "\n";
            $filecontent .= '  <div id="url"><a href="' . spch($content_filename) . '"><!--###BOOKMARK_FILE_URL###-->' . spch($content_filename) . '<!--###BOOKMARK_FILE_URL###--></a></div>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_FILE_DESC###-->' . spch_text($file->intro) . '<!--###BOOKMARK_FILE_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $file->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($file->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $file->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    $notes = get_category_items($id, $viewid, 'note');
    if ($notes) {
        $hasItems = true;
        foreach ($notes as $note) {
            unset($filecontent);
            unset($filename);
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch($note->name) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch($note->name) . '</h1>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_NOTE_DESC###-->' . spch_text($note->intro) . '<!--###BOOKMARK_NOTE_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $note->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($note->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $note->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    return $hasItems;
}
function block_exabis_eportfolio_get_epx_category_content(&$xmlElement, &$resources, $id, $exportpath, $export_dir, &$ridentifier, $viewid)
{
    global $USER, $CFG, $COURSE;
    $bookmarks = get_category_items($id, $viewid, 'link');
    if ($bookmarks) {
        foreach ($bookmarks as $bookmark) {
            unset($thisitem);
            unset($thisitemtitle);
            unset($thisitemdescription);
            unset($thisitemurl);
            unset($itemref);
            $itemidentifier = $ridentifier;
            $ridentifier++;
            $thisitem =& $resources->createChild('epx:item');
            $thisitem->attribute('id', 'link' . $itemidentifier);
            $thisitem->attribute('created', date("c", $bookmark->timemodified));
            $thisitem->attribute('lastedited', date("c", $bookmark->timemodified));
            $thisitem->attribute('editable', 'true');
            $thisitem->attribute('visible', 'true');
            $thisitem->attribute('xsi:type', 'epx:linkType');
            $thisitem->attribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
            block_exabis_eportfolio_get_comments_for_item($thisitem, 'block_exabeporitemcomm', $bookmark->id, $ridentifier);
            $thisitemtitle =& $thisitem->createChild('epx:title');
            $thisitemtitle->cdata(spch($bookmark->name));
            $thisitemdescription =& $thisitem->createChild('epx:description');
            $thisitemdescription->cdata(spch($bookmark->intro));
            $thisitemurl =& $thisitem->createChild('epx:url');
            $thisitemurl->cdata(spch($bookmark->url));
            $itemref =& $xmlElement->createChild('epx:itemref');
            $itemref->attribute('id', 'link' . $itemidentifier);
        }
    }
    $files = get_category_items($id, $viewid, 'file');
    if ($files) {
        foreach ($files as $file) {
            unset($thisitem);
            unset($thisitemtitle);
            unset($thisitemdescription);
            unset($thisitemuri);
            unset($itemref);
            $itemidentifier = $ridentifier;
            $ridentifier++;
            $i = 0;
            $content_filename = $file->attachment;
            if (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename)) {
                do {
                    $i++;
                    $content_filename = $i . $file->attachment;
                } while (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename));
            }
            if ($file->attachment != '') {
                copy($CFG->dataroot . "/" . block_exabis_eportfolio_file_area_name($file) . "/" . $file->attachment, $exportpath . $export_dir . $content_filename);
            }
            $thisitem =& $resources->createChild('epx:item');
            $thisitem->attribute('id', 'file' . $itemidentifier);
            $thisitem->attribute('created', date("c", $file->timemodified));
            $thisitem->attribute('lastedited', date("c", $file->timemodified));
            $thisitem->attribute('editable', 'true');
            $thisitem->attribute('visible', 'true');
            $thisitem->attribute('xsi:type', 'epx:fileType');
            $thisitem->attribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
            block_exabis_eportfolio_get_comments_for_item($thisitem, 'block_exabeporitemcomm', $file->id, $ridentifier);
            $thisitemtitle =& $thisitem->createChild('epx:title');
            $thisitemtitle->cdata(spch($file->name));
            $thisitemdescription =& $thisitem->createChild('epx:text');
            $thisitemdescription->cdata(spch($file->intro));
            $thisitemuri =& $thisitem->createChild('epx:uri');
            $thisitemuri->cdata(spch('epx:' . $export_dir . $content_filename));
            $itemref =& $xmlElement->createChild('epx:itemref');
            $itemref->attribute('id', 'file' . $itemidentifier);
        }
    }
    $notes = get_category_items($id, $viewid, 'note');
    if ($notes) {
        foreach ($notes as $note) {
            unset($thisitem);
            unset($thisitemtitle);
            unset($thisitemdescription);
            unset($itemref);
            $itemidentifier = $ridentifier;
            $ridentifier++;
            $thisitem =& $resources->createChild('epx:item');
            $thisitem->attribute('id', 'note' . $itemidentifier);
            $thisitem->attribute('created', date("c", $note->timemodified));
            $thisitem->attribute('lastedited', date("c", $note->timemodified));
            $thisitem->attribute('editable', 'true');
            $thisitem->attribute('visible', 'true');
            $thisitem->attribute('xsi:type', 'epx:noteType');
            $thisitem->attribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
            block_exabis_eportfolio_get_comments_for_item($thisitem, 'block_exabeporitemcomm', $note->id, $ridentifier);
            $thisitemtitle =& $thisitem->createChild('epx:title');
            $thisitemtitle->cdata(spch($note->name));
            $thisitemdescription =& $thisitem->createChild('epx:text');
            $thisitemdescription->cdata(spch($note->intro));
            $itemref =& $xmlElement->createChild('epx:itemref');
            $itemref->attribute('id', 'note' . $itemidentifier);
        }
    }
    return true;
}