コード例 #1
0
ファイル: Tagger.php プロジェクト: jubinpatel/horde
 /**
  * References a file.
  * Parses the files contents for symbols and creates references to the
  * files where these symbols are defined.
  *
  * @param Luxor_Driver $files   An instance of a storage backend driver.
  * @param string $pathname      The (relative) pathname of the file to
  *                              be referenced.
  * @param Luxor_Lang $lang      The language object for $pathname.
  *
  * @return mixed                A PEAR_Error if an error occured.
  */
 function processRefs($files, $pathname, $lang)
 {
     global $index;
     /* Get the unique ID for this file. */
     $fileId = $index->fileId($pathname);
     if ($fileId === false) {
         $fileId = $index->createFileId($pathname, '', $files->getFiletime($pathname));
     }
     if (is_a($fileId, 'PEAR_Error')) {
         return $fileId;
     }
     /* Update the file's status. */
     $result = $index->toReference($fileId);
     if ($result === false) {
         return PEAR::raiseError(sprintf(_("%s was already indexed."), $pathname));
     } elseif (is_a($result, 'PEAR_Error')) {
         return $result;
     }
     /* Empty symbol cache. */
     $index->clearCache();
     /* Create references to symbol definitions. */
     $path = $files->tmpFile($pathname);
     if (!$path) {
         return PEAR::raiseError(sprintf(_("Can't create copy of file %s."), $pathname));
     }
     $result = $lang->referenceFile($path, $fileId);
     if (is_a($result, 'PEAR_Error')) {
         return $result;
     }
 }
コード例 #2
0
ファイル: Luxor.php プロジェクト: jubinpatel/horde
 /**
  * Initial app setup code.
  */
 public static function initialize()
 {
     global $sources, $sourceid, $source, $files, $index, $pathname;
     require LUXOR_BASE . '/config/backends.php';
     /* Default to the first source; overridden elsewhere if necessary. */
     $sourceid = Horde_Util::getFormData('source');
     if (!isset($sources[$sourceid])) {
         $sourceid = key($sources);
     }
     $source = $sources[$sourceid];
     $files = Luxor_Files::factory($source['driver'], $source);
     $index = Luxor_Driver::factory($sourceid);
     $pathname = Luxor::fixPaths(Horde_Util::getFormData('f'));
 }
コード例 #3
0
ファイル: symbol.php プロジェクト: horde/horde
 * did not receive this file, see http://www.horde.org/licenses/gpl.php.
 *
 * @author Jan Schneider <*****@*****.**>
 * @author Mike Cochrane <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('luxor');
$ident = Horde_Util::getFormData('i');
// Change source if the symbol isn't from the current source.
$symbolSource = $index->getSourceBySymbol($ident);
if (!$symbolSource) {
    throw new Horde_Exception(_("Symbol not found"));
}
if ($symbolSource != $sourceid) {
    $source = $sources[$symbolSource];
    $index = Luxor_Driver::factory($symbolSource);
}
$declarations = $index->getIndex($ident);
$sorted = array();
foreach ($declarations as $decl) {
    $sorted[$decl['declaration']][] = array('filename' => $decl['filename'], 'line' => $decl['line']);
}
$ds = array();
foreach ($sorted as $type => $locations) {
    $d = array();
    $d['title'] = sprintf(_("Declared as a %s"), $type);
    $d['files'] = array();
    Horde_Array::arraySort($locations, 'filename', 0, false);
    foreach ($locations as $loc) {
        $href = Luxor::url($loc['filename'], array(), 'l' . $loc['line']);
        $d['files'][] = '<a href="' . $href . '">' . $loc['filename'] . ' ' . sprintf(_("Line %s"), $loc['line']) . '</a>';