/**
  * Export all pages
  * 
  * @param string $a_target_directory
  * @param string $a_link_template (embedded)
  * @param array $a_tpl_callback (embedded)
  * @param object $a_co_page_html_export (embedded)
  * @param string $a_index_name (embedded)
  */
 function exportHTMLPages($a_target_directory, $a_link_template = null, $a_tpl_callback = null, $a_co_page_html_export = null, $a_index_name = "index.html")
 {
     if (!$a_link_template) {
         $a_link_template = "bl{TYPE}_{ID}.html";
     }
     if ($a_co_page_html_export) {
         $this->co_page_html_export = $a_co_page_html_export;
     }
     $nav = $this->renderNavigation($this->items, "", "", $a_link_template);
     // month list
     $has_index = false;
     foreach (array_keys($this->items) as $month) {
         $file = $this->buildExportLink($a_link_template, "list", $month);
         $list = $this->renderList($this->items[$month], "render", $a_link_template, false, $a_target_directory);
         if (!$a_tpl_callback) {
             $tpl = $this->buildExportTemplate();
         } else {
             $tpl = call_user_func($a_tpl_callback);
         }
         $file = $this->writeExportFile($a_target_directory, $file, $tpl, $list, $nav);
         if (!$has_index) {
             copy($file, $a_target_directory . "/" . $a_index_name);
             $has_index = true;
         }
     }
     // single postings
     include_once "./Services/COPage/classes/class.ilPageContentUsage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $pages = ilBlogPosting::getAllPostings($this->object->getId(), 0);
     foreach ($pages as $page) {
         if (ilBlogPosting::_exists("blp", $page["id"])) {
             include_once "./Modules/Blog/classes/class.ilBlogPostingGUI.php";
             $blp_gui = new ilBlogPostingGUI(0, null, $page["id"]);
             $blp_gui->setOutputMode("offline");
             $blp_gui->setFullscreenLink("fullscreen.html");
             // #12930 - see page.xsl
             $blp_gui->add_date = true;
             $page_content = $blp_gui->showPage();
             $back = $this->buildExportLink($a_link_template, "list", substr($page["created"]->get(IL_CAL_DATE), 0, 7));
             $file = $this->buildExportLink($a_link_template, "posting", $page["id"]);
             if (!$a_tpl_callback) {
                 $tpl = $this->buildExportTemplate();
             } else {
                 $tpl = call_user_func($a_tpl_callback);
             }
             $this->writeExportFile($a_target_directory, $file, $tpl, $page_content, $nav, $back);
             $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
         }
     }
     $this->co_page_html_export->exportPageElements();
 }