function printfile_markup($pathname) { $ann = $GLOBALS['files']->getAnnotations($pathname); /* Commented out until we have a driver that supports annotations. this formatting should probably be done in markupFile(); if (is_array($ann)) { $b = null; for ($i = 0; $i < count($ann); $i++) { if ($ann[$i] == $b) { $ann[$i] = str_repeat(' ', 16); continue; } $b = $ann[$i]; $ann[$i] .= str_repeat(' ', 6 - strlen($ann[$i])) . $files->getAuthor($pathname); $ann[$i] .= str_repeat(' ', 16 - strlen($ann[$i])); } } */ $fileh = $GLOBALS['files']->getFileHandle($pathname); if (!$fileh) { $GLOBALS['notification']->push(sprintf(_("The file %s can't be opened or doesn't exist."), $pathname), 'horde.error'); return; } $output = Luxor::markupFile($pathname, $fileh, $ann); if ($output === false) { $GLOBALS['notification']->push(sprintf(_("Could not markup file %s."), $pathname), 'horde.warning'); return printfile_raw($pathname); } return $output; }
function processInclude($frag, $dir) { $callback1 = function ($match) use($dir) { return stripslashes($match[1]) . Luxor::incRef($match[2], 'fixed', $match[2], $dir) . stripslashes($match[3]); }; $callback2 = function ($match) { return stripslashes($match[1]) . Luxor::incRef($match[2], 'fixed', $match[2]) . stripslashes($match[3]); }; return preg_replace(array('/([\'"])(.*?)([\'"])/e', '/(\\0<)(.*?)(\\0>)/e'), array($callback1, $callback2), $frag); }
/** */ 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>'; }
/** * Global variables defined: * $luxor_shares - TODO */ protected function _init() { Luxor::initialize(); }
} $references = $index->getReference($ident); Horde_Array::arraySort($references, 'filename', 0, false); $curfile = ''; $rs = array(); $r = array(); foreach ($references as $info) { if ($curfile != $info['filename']) { if ($r) { $rs[] = $r; } $curfile = $info['filename']; $r = array(); $r['file'] = '<a href="' . Luxor::url($info['filename']) . '">' . htmlspecialchars($info['filename']) . '</a>'; $r['lines'] = array(); } $r['lines'][] = '<a href="' . Luxor::url($info['filename'], array(), 'l' . $info['line']) . '">' . sprintf(_("Line %s"), $info['line']) . '</a>'; } if ($r) { $rs[] = $r; } $title = sprintf(_("%s :: Symbol \"%s\""), $source['name'], $index->symname($ident)); $page_output->header(array('title' => $title)); require LUXOR_TEMPLATES . '/menu.inc'; $view = new Horde_View(array('templatePath' => LUXOR_TEMPLATES)); $view->addHelper('Text'); $view->title = $title; $view->declarations = $ds; $view->references = $rs; echo $view->render('symbol.html.php'); $page_output->footer();
/** * Returns a directory's content. Backup files are skipped and * directories suffixed with a slash. * * @param string $path The directory to list. * * @return array An array containing all directories and files of * the directory or PEAR_Error if the directory * couldn't be read. */ function getDir($path, $release = '') { $path = $this->toReal($path); $dir = @opendir($path); if (!$dir) { return PEAR::raiseError(sprintf(_("Can't open directory %s"), $path)); } $dirs = array(); $files = array(); while (($file = readdir($dir)) !== false) { if (preg_match('/^\\.|~$|\\.orig$|\\.bak$/i', $file) || is_dir($path . $file) && $file == 'CVS') { continue; } if (is_dir($path . $file)) { if (Luxor::isDirParsed($path . $file)) { $dirs[] = $file . '/'; } } else { if (Luxor::isFileParsed($path . $file)) { $files[] = $file; } } } closedir($dir); natcasesort($dirs); natcasesort($files); return array_merge($dirs, $files); }
$id = current($ids); Horde::url('symbol.php', true)->add('i', $id)->redirect(); } // If there are multiple search results, display some info for all of them. $page_output->header(array('title' => sprintf(_("Symbol Search for \"%s\""), $symbol))); require LUXOR_TEMPLATES . '/menu.inc'; echo '<h1 class="header">' . htmlspecialchars($title) . '</h1>'; foreach ($ids as $ident) { // Change source if the symbol isn't from the current source. $symbolSource = $index->getSourceBySymbol($ident); if ($symbolSource != $sourceid) { $source = $sources[$symbolSource]; $index = Luxor_Driver::factory($symbolSource); } $name = $index->symname($ident); echo '<br /><span class="header">' . Horde::link(Horde::url('symbol.php?i=' . $ident), $name, 'header') . $name . '</a></span><br />'; $references = $index->getIndex($ident); $sorted = array(); foreach ($references as $ref) { $sorted[$ref['declaration']][] = array('filename' => $ref['filename'], 'line' => $ref['line']); } foreach ($sorted as $type => $locations) { echo _("Declared as ") . $type . "\n"; foreach ($locations as $loc) { $href = Luxor::url($loc['filename'], array(), 'l' . $loc['line']); echo ' <a href="' . $href . '">' . $loc['filename'] . ' Line: ' . $loc['line'] . '</a><br />'; } echo '<br />'; } } $page_output->footer();