in['path'], -1, PREG_SPLIT_NO_EMPTY); $input =& BSRegister::Get('input'); $html = '[' . $input->in['repos'] . ']: '; if (empty($path)) { return $html . '/'; } $build = ''; foreach ($path AS $index => $part) { $build .= '/' . $part; if (sizeof($path) - 1 == $index) { $html .= '/ ' . $part . ''; } else { $html .= '/ ' . $part . ' '; } } return $html; } // ################################################################### /** * Formats an array of properties into a compiled HTML template * * @param array Array of properties * * @return string Compiled HTML property list */ function FormatPropList($props) { if (sizeof($props) < 0) { return ''; } foreach ($props AS $propname => $propval) { $data = sprintf(_('Property %1$s set to %2$s'), $propname, $propval); eval('$proplist .= "' . BSRegister::Get('template')->fetch('property') . '";'); } return $proplist; } // ################################################################### /** * Formats a SVN log message * * @param string Unformatted log message * * @return string Output-ready log message */ function FormatLogMessage($message) { global $viewsvn; $message = BSRegister::Get('input')->entityEncode($message); // TODO - fix the revision links // $message = preg_replace('#r([0-9]+)#e', '"maincontrol->href_struct("diff.php" . Paths::fetch_rev_str(true, "\1", 0), "/") . "\">r\1"', $message); $list = false; $lines = explode("\n", $message); $message = ''; foreach ($lines AS $line) { if (preg_match('#^\s*?(\*|\-)\s?(.*)#', $line, $matches)) { if ($list) { $message .= '
  • ' . $matches[2] . '
  • '; } else { $message .= ''; $message .= $line; } else { $message .= $line; $message .= '
    '; } $list = false; } $message .= "\n"; } if ($list) { $message .= ''; } $message = preg_replace('#(
    )*$#', '', $message); return $message; } // ################################################################### /** * Parses a date from SVN into something more human-friendly * * @param string Date string * * @return string Formatted and readable date string */ function FormatSvnDate($string) { // 2005-01-23T20:42:53.703057Z return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string); } // ################################################################### /** * Generates an absolute-pathed link if you just pass it the four * paramaters * * @param string Action/script * @param string Repository name * @param string Subpath in repository * @param integer Revision * * @return string Link (not wrapped in ) */ function ConstructLink($action, $repos, $path, $rev) { return BSRegister::Get('webpath') . '/' . $action . '/' . $repos . ':' . $path . ($rev > 0 ? '@' . $rev : ''); } // ################################################################### /** * Prepares data for output * * @param string Standard data * * @return string Output-ready data */ function FormatCode($string) { // convert entities $string = htmlspecialchars($string); // tabs to 5 spaces $string = str_replace("\t", ' ', $string); // spaces to nbsp if (true) { $string = preg_replace('#( +)#e', '_FormatSpaces("\1")', $string); } // no word wrap else { $string = str_replace(' ', ' ', $string); } // convert advanced diff $string = str_replace(array('{@+' . '+}', '{@-' . '-}'), array('', ''), $string); $string = str_replace(array('{/@+' . '+}', '{/@-' . '-}'), '', $string); // nl2br $string = nl2br($string); return $string; } // ################################################################### /** * Counts the spaces and replaces two or more ones * * @param string Spaced string * * @return string  'd string */ function _FormatSpaces($thestring) { if (strlen($thestring) >= 2) { $thestring = str_replace(' ', ' ', $thestring); } return $thestring; } // ################################################################### /** * Takes in an array of files with a path and an action and constructs * the HTML block describing them * * @param array List of file changes * @param string The repository * @param integer Current revision * * @return string Processed HTML */ function ConstructFileChanges($changes, $repos, $revision) { $files = ''; foreach ($changes AS $file) { switch ($file['action']) { case 'A': $class = 'file_add'; $tooltip = _('Added'); break; case 'D': $class = 'file_delete'; $tooltip = _('Deleted'); break; case 'M': $class = 'file_modify'; $tooltip = _('Modified'); break; case 'R': $class = 'file_replace'; $tooltip = _('Replaced'); break; } $show['from'] = (bool)$file['from']; if ($file['from']) { $class = 'file_move'; $tooltip = _('Moved/Copied'); preg_match('#(.*):([0-9]+)#', $file['from'], $matches); $link['from'] = ConstructLink('view', $repos, $matches[1], $revision); } $link['file'] = ConstructLink('view', $repos, $file['value'], $revision); eval('$files .= "' . BSRegister::Get('template')->fetch('file_change') . '";'); } return $files; } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>