Example #1
0
 /**
  * write current output buffer to file
  *
  * @param  file path
  * @param  formating flags
  * @access private
  */
 function write()
 {
     $stat = true;
     if ($this->path) {
         $text = ob_get_clean();
         $fp = new CodeGen_Tools_FileReplacer($this->path);
         if ($this->flags && self::OB_TABIFY) {
             $text = CodeGen_Tools_Indent::tabify($text);
         } else {
             if ($this->flags && self::OB_UNTABIFY) {
                 $text = CodeGen_Tools_Indent::untabify($text);
             }
         }
         if ($this->flags && self::OB_DOSIFY) {
             $text = CodeGen_Tools_Indent::tabify($text);
         }
         $fp->puts($text);
         $stat = $fp->close();
         $this->path = "";
     }
     return $stat;
 }
Example #2
0
 /**
  * re-indent a block of text
  *
  * with C/C++ we need to make sure that preporcessor
  * directives always start on the first column
  *
  * @access public
  * @param  int    number of leading indent spaces
  * @param  string text to reindent
  * @return string indented text
  */
 function indent($level, $text)
 {
     $result = parent::indent($level, $text);
     return preg_replace('/^\\s+#/m', '#', $result);
 }
 function tagend_extension_code($attr, $data)
 {
     $err = $this->checkAttributes($attr, array("role", "position"));
     if (PEAR::isError($err)) {
         return $err;
     }
     $role = isset($attr["role"]) ? $attr["role"] : "code";
     $position = isset($attr["position"]) ? $attr["position"] : "bottom";
     if (isset($attr["src"])) {
         return $this->extension->addCode($role, $position, CodeGen_Tools_Indent::linetrim(file_get_contents($attr["src"])));
     } else {
         return $this->extension->addCode($role, $position, CodeGen_Tools_Indent::linetrim($data));
     }
 }