Exemplo n.º 1
0
 /**
  */
 function markupfile($pathname, $fileh, $ann = array())
 {
     global $files, $conf;
     preg_match_all('|^(.*/)|', $pathname, $dir);
     $dir = $dir[0];
     /* Determine the file's language and create a Luxor_Lang
      * instance. */
     $lang =& Luxor_Lang::builder($files, $pathname);
     if (is_a($lang, 'PEAR_Error')) {
         return $lang;
     }
     $html = '<table cellspacing="0" width="100%" class="text">';
     // A source code file.
     if (!$lang) {
         return false;
     }
     $parser = new Luxor_SimpleParse($fileh, 1, $lang->_langmap['spec']);
     $linenum = 1;
     list($btype, $frag) = $parser->nextFrag();
     $ofrag = '';
     while ($frag) {
         $frag = preg_replace('/([&<>])/', chr(0) . '$1', $frag);
         switch ($btype) {
             case 'comment':
                 // Comment
                 // Convert mail adresses to mailto:
                 // &freetextmarkup($frag);
                 // $lang->processComment(\$frag);
                 $frag = Luxor::fixString($frag, '<span class="comment">', '</span>');
                 break;
             case 'string':
                 $frag = Luxor::fixString($frag, '<span class="string">', '</span>');
                 break;
             case 'include':
                 // Include directive
                 $frag = $lang->processInclude($frag, $dir);
                 break;
             case 'variable':
                 if (!empty($conf['options']['use_show_var'])) {
                     $pre = sprintf('<span class="variable"><span class="var_%s" onmouseover="show_var(\'var_%s\');" onmouseout="unshow_var(\'var_%s\');">', substr($frag, 1), substr($frag, 1), substr($frag, 1));
                     $frag = Luxor::fixString($frag, $pre, '</span></span>');
                 } else {
                     $frag = Luxor::fixString($frag, '<span class="variable">', '</span>');
                 }
                 break;
             default:
                 // Code
                 // somehow get $source['may_reference'] into the second parameter here.
                 $frag = $lang->processCode($frag);
         }
         $frag = preg_replace('/\\0([&<>])/', '$1', $frag);
         $ofrag .= $frag;
         list($btype, $frag) = $parser->nextFrag();
     }
     $lines = preg_split('(\\r\\n|\\n|\\r)', $ofrag);
     foreach ($lines as $line) {
         $html .= '<tr><td align="right" style="padding-left:10px; padding-right:10px;"><a id="l' . $linenum . '" class="fixed" style="color:black">' . $linenum++ . '</a></td><td width="100%" class="fixed">' . $line . "</td></tr>\n";
     }
     return $html . '</table>';
 }