Beispiel #1
0
 /**
  * Return the page output (HTML / Raw)
  *
  * @param array $headers Output headers
  *
  * @return string|\DOMDocument
  */
 public function getOutput(array &$headers = array())
 {
     $this->_prepareOptions();
     $this->_prepareSearch();
     $this->_prepareTree();
     // Raw output?
     switch ($this->_options->get(Opt::OUTPUT_TYPE)) {
         case Opt::OUTPUT_TYPE_RAW:
             $headers['Content-type'] = 'text/plain; charset=UTF-8';
             $current_file = $this->_search->getCurrentFile(false);
             if ($this->_search->isCurrentFileValid() && is_file($current_file)) {
                 $file_encoder = new FileEncoder($current_file);
                 $output = $file_encoder->getFileContents();
             } else {
                 $output = 'Your current selection is not valid.';
             }
             break;
         case Opt::OUTPUT_TYPE_DOM:
             $headers['Content-type'] = 'text/html; charset=UTF-8';
             $this->_tree->buildTree();
             $this->_preparePage();
             $output = $this->_page->getDOMDocument();
             break;
         default:
             $output = 'No valid output type set.';
     }
     return $output;
 }
Beispiel #2
0
 /**
  * Return the options (wrapper)
  *
  * @return Options
  */
 public function getOptions()
 {
     return $this->_tree->getOptions();
 }