예제 #1
0
 public function PrintBuf(&$buf, $level = 0)
 {
     $note0 = $this->_fileline == NULL ? '' : $this->_fileline->_note0;
     $note1 = $this->_fileline == NULL ? '' : $this->_fileline->_note1;
     $key = $this->_print_k;
     $alias_note = '';
     if (($key1 = DKeywordAlias::GetShortPrintKey($this->_k)) != NULL) {
         $key = $key1;
         if ($note0 == '' && $key != $this->_raw_k) {
             $alias_note = "# {$key} is shortened alias of {$this->_print_k} \n";
         }
     }
     if ($note0 != '') {
         $buf .= str_replace("\n\n", "\n", $note0);
     }
     if ($this->_errlevel > 0) {
         $buf .= "#__ERR__({$this->_errlevel}): {$this->_e} \n";
     }
     if ($this->_type & self::BM_IDX) {
         return;
     }
     // do not print index node
     $indent = str_pad('', $level * 2);
     $val = $this->_v;
     if ($val != '' && strpos($val, "\n")) {
         $val = "<<<END_{$key}\n{$val}\n{$indent}END_{$key}\n";
     }
     if ($this->_type & self::BM_VAL && !($this->_type & self::BM_BLK)) {
         // do not print empty value
         if ($val != '' || $note0 != '' || $this->_errlevel > 0) {
             $width = self::KEY_WIDTH - $level * 2;
             $buf .= $alias_note;
             $buf .= $indent . str_pad($key, $width) . " {$val}\n";
         }
     } else {
         $begin = '';
         $end = '';
         $buf1 = '';
         $buf2 = '';
         if ($this->_type & self::BM_BLK) {
             if ($note0 == '') {
                 $buf1 .= "\n";
             }
             $buf1 .= $alias_note;
             $buf1 .= "{$indent}{$key} {$val}";
             $begin = " {\n";
             $end = "{$indent}}\n";
             $level++;
         } elseif ($this->_type == self::T_INC) {
             $buf1 .= "{$indent}{$key} {$val}\n";
             $buf1 .= "\n##__INC__\n";
             $end = "\n##__ENDINC__\n";
         }
         foreach ($this->_els as $el) {
             if (is_array($el)) {
                 foreach ($el as $child) {
                     $child->PrintBuf($buf2, $level);
                 }
             } else {
                 $el->PrintBuf($buf2, $level);
             }
         }
         if ($note1 != '') {
             $buf2 .= str_replace("\n\n", "\n", $note1);
         }
         // do not print empty block
         if ($val != '' || $buf2 != '') {
             if ($buf2 == '') {
                 $buf .= $buf1 . "\n";
             } else {
                 $buf .= $buf1 . $begin . $buf2 . $end;
             }
         }
     }
 }
예제 #2
0
 public static function GetShortPrintKey($normalizedkey)
 {
     $tool = DKeywordAlias::GetInstance();
     return $tool->get_short_print_key($normalizedkey);
 }