Example #1
0
 public function dump_export_data()
 {
     foreach ($this->exporter->get('artefacts') as $artefact) {
         if ($artefact->get('artefacttype') == 'blog') {
             // Create directory for storing the blog
             $dirname = PluginExportHtml::text_to_path($artefact->get('title'));
             if (!check_dir_exists($this->fileroot . $dirname)) {
                 throw new SystemException("Couldn't create blog directory {$this->fileroot}{$dirname}");
             }
             // Render the first page of the blog (the only one if there's
             // not many posts)
             $smarty = $this->exporter->get_smarty('../../../', 'blog');
             $smarty->assign('page_heading', $artefact->get('title'));
             $smarty->assign('breadcrumbs', array(array('text' => get_string('blogs', 'artefact.blog')), array('text' => $artefact->get('title'), 'path' => 'index.html')));
             $rendered = $artefact->render_self(array('hidetitle' => true));
             $outputfilter = new HtmlExportOutputFilter('../../../');
             $smarty->assign('rendered_blog', $outputfilter->filter($rendered['html']));
             $content = $smarty->fetch('export:html/blog:index.tpl');
             if (false === file_put_contents($this->fileroot . $dirname . '/index.html', $content)) {
                 throw new SystemException("Unable to create index.html for blog {$blogid}");
             }
             // If the blog has many posts, we'll need to write out archive pages
             $postcount = $artefact->count_published_posts();
             $perpage = ArtefactTypeBlog::pagination;
             if ($postcount > $perpage) {
                 for ($i = 2; $i <= ceil($postcount / $perpage); $i++) {
                     $rendered = $artefact->render_self(array('page' => $i));
                     $smarty->assign('rendered_blog', $outputfilter->filter($rendered['html']));
                     $content = $smarty->fetch('export:html/blog:index.tpl');
                     if (false === file_put_contents($this->fileroot . $dirname . "/{$i}.html", $content)) {
                         throw new SystemException("Unable to create {$i}.html for blog {$artefact->get('id')}");
                     }
                 }
             }
         }
     }
 }
Example #2
0
 public function get_summary()
 {
     $smarty = $this->exporter->get_smarty();
     $outputfilter = new HtmlExportOutputFilter('.', $this->exporter);
     $smarty->assign('introduction', $outputfilter->filter(get_profile_field($this->exporter->get('user')->get('id'), 'introduction')));
     $smarty->assign('profileviewexported', $this->profileviewexported);
     $iconid = $this->exporter->get('user')->get('profileicon');
     if ($iconid) {
         $icon = artefact_instance_from_id($iconid);
         $smarty->assign('icon', '<img src="static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Picture">');
     }
     return array('description' => $smarty->fetch('export:html/internal:summary.tpl'));
 }
Example #3
0
 public function paginate($artefact)
 {
     // Create directory for storing the artefact
     $dirname = PluginExportHtml::text_to_filename(trim($artefact->get('title')));
     if (!check_dir_exists($this->fileroot . $dirname)) {
         throw new SystemException("Couldn't create artefact directory {$this->fileroot}{$dirname}");
     }
     // Get artefact-specific pagination options
     $options = $this->pagination_data($artefact);
     // Render the first page of the artefact (the only one if there aren't many children)
     $smarty = $this->exporter->get_smarty('../../../', $artefact->get('artefacttype'));
     $smarty->assign('page_heading', $artefact->get('title'));
     $smarty->assign('breadcrumbs', array(array('text' => $options['plural']), array('text' => $artefact->get('title'), 'path' => 'index.html')));
     $rendered = $artefact->render_self(array('hidetitle' => true));
     $outputfilter = new HtmlExportOutputFilter('../../../', $this->exporter);
     $smarty->assign('rendered', $outputfilter->filter($rendered['html']));
     $content = $smarty->fetch('export:html:page.tpl');
     if (false === file_put_contents($this->fileroot . $dirname . '/index.html', $content)) {
         throw new SystemException("Unable to create index.html for artefact " . $artefact->get('id'));
     }
     // If the artefact has many children, we'll need to write out archive pages
     if ($options['childcount'] > $options['perpage']) {
         for ($i = $options['perpage']; $i <= $options['childcount']; $i += $options['perpage']) {
             $rendered = $artefact->render_self(array('limit' => $options['perpage'], 'offset' => $i));
             $smarty->assign('rendered', $outputfilter->filter($rendered['html']));
             $content = $smarty->fetch('export:html:page.tpl');
             if (false === file_put_contents($this->fileroot . $dirname . "/{$i}.html", $content)) {
                 throw new SystemException("Unable to create {$i}.html for artefact {$artefact->get('id')}");
             }
         }
     }
 }
Example #4
0
 /**
  * Dumps all views into the HTML export
  */
 private function dump_view_export_data()
 {
     $progressstart = 55;
     $progressend = 75;
     $i = 0;
     $viewcount = count($this->views);
     $rootpath = $this->exportingoneview ? './' : '../../';
     $smarty = $this->get_smarty($rootpath);
     foreach ($this->views as $viewid => $view) {
         $this->notify_progress_callback(intval($progressstart + ++$i / $viewcount * ($progressend - $progressstart)), "Exporting Views ({$i}/{$viewcount})");
         $smarty->assign('page_heading', $view->get('title'));
         $smarty->assign('viewdescription', $view->get('description'));
         if ($this->exportingoneview) {
             $smarty->assign('nobreadcrumbs', true);
             $directory = $this->exportdir . '/' . $this->rootdir;
         } else {
             $smarty->assign('breadcrumbs', array(array('text' => get_string('Views', 'view')), array('text' => $view->get('title'), 'path' => 'index.html')));
             $directory = $this->exportdir . '/' . $this->rootdir . '/views/' . self::text_to_path($view->get('title'));
             if (!check_dir_exists($directory)) {
                 throw new SystemException("Could not create directory for view {$viewid}");
             }
         }
         $outputfilter = new HtmlExportOutputFilter($rootpath);
         $smarty->assign('view', $outputfilter->filter($view->build_columns()));
         $content = $smarty->fetch('export:html:view.tpl');
         if (!file_put_contents("{$directory}/index.html", $content)) {
             throw new SystemException("Could not write view page for view {$viewid}");
         }
     }
 }