/**
* Chora Base Class.
*
+ * Copyright 2000-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
* @author Anil Madhavapeddy <avsm@horde.org>
* @package Chora
*/
-class Chora {
-
+class Chora
+{
/**
* Return a text description of how long its been since the file
* has been last modified.
*
* @return string The human-readable date.
*/
- function readableTime($date, $long = false)
+ static public function readableTime($date, $long = false)
{
static $time, $desc, $breaks;
/**
* Initialize global variables and objects.
*/
- function initialize()
+ static public function initialize()
{
global $acts, $defaultActs, $conf, $where, $atdir, $fullname, $prefs,
$sourceroot, $scriptName;
* TODO: defaults of 1 will not get propagated correctly - avsm
* XXX: Rewrite this propagation code, since it sucks - avsm
*/
- $defaultActs = array('sbt' => constant($conf['options']['defaultsort']),
- 'sa' => 0,
- 'ord' => Horde_Vcs::SORT_ASCENDING,
- 'ws' => 1);
+ $defaultActs = array(
+ 'sbt' => constant($conf['options']['defaultsort']),
+ 'sa' => 0,
+ 'ord' => Horde_Vcs::SORT_ASCENDING,
+ 'ws' => 1
+ );
/* Use the last sourceroot used as the default value if the user
* has that preference. */
}
/* Location relative to the sourceroot. */
- $where = preg_replace('|^/|', '', $where);
- $where = preg_replace('|\.\.|', '', $where);
+ $where = preg_replace(array('|^/|', '|\.\.|'), '', $where);
/* Location of this script (e.g. /chora/browse.php). */
- $scriptName = preg_replace('|^/?|', '/', $_SERVER['PHP_SELF']);
- $scriptName = preg_replace('|/$|', '', $scriptName);
+ $scriptName = preg_replace(array('|^/?|', '|/$|'), array('/', ''), $_SERVER['PHP_SELF']);
/* Store last file/repository viewed, and set 'where' to
* last_file if necessary. */
}
$where = preg_replace('|/$|', '', $where);
- if ($sourcerootopts['type'] == 'cvs' && !@is_dir($sourcerootopts['location'])) {
+ if (($sourcerootopts['type'] == 'cvs') &&
+ !@is_dir($sourcerootopts['location'])) {
Chora::fatal(_("Sourceroot not found. This could be a misconfiguration by the server administrator, or the server could be having temporary problems. Please try again later."), '500 Internal Server Error');
}
}
}
- function whereMenu()
+ static public function whereMenu()
{
global $where, $atdir;
* for sending 404s or other codes if
* appropriate..
*/
- public static function fatal($message, $responseCode = null)
+ static public function fatal($message, $responseCode = null)
{
if (defined('CHORA_ERROR_HANDLER') && constant('CHORA_ERROR_HANDLER')) {
return;
*
* @param mixed $e Return object from a Horde_Vcs:: call.
*/
- function checkError($e)
+ static public function checkError($e)
{
if (is_a($e, 'PEAR_Error')) {
Chora::fatal($e->getMessage());
*
* @return string The transformed name.
*/
- function showAuthorName($name, $fullname = false)
+ static public function showAuthorName($name, $fullname = false)
{
static $users = null;
*
* @return string The URL, with session information if necessary.
*/
- function url($script = '', $uri = '', $args = array(), $anchor = '')
+ static public function url($script = '', $uri = '', $args = array(),
+ $anchor = '')
{
global $conf, $acts, $defaultActs;
$url = Util::addParameter(Horde::applicationUrl($script), $arglist);
if (!empty($anchor)) {
- $url .= "#$anchor";
+ $url .= '#' . $anchor;
}
return $url;
*
* @return string The form fields, with session information if necessary.
*/
- function formInputs($args = array())
+ static public function formInputs($args = array())
{
global $conf, $acts, $defaultActs;
*
* @return array The sourceroots that the current user has access to.
*/
- function sourceroots()
+ static public function sourceroots()
{
global $perms, $sourceroot, $sourceroots;
*
* @return string XHTML code representing links to the repositories.
*/
- function repositories()
+ static public function repositories()
{
$sourceroots = Chora::sourceroots();
$num_repositories = count($sourceroots);
* @return mixed The Horde_Mime_Viewer object which can be rendered or
* false on failure.
*/
- function pretty($mime_type, $fp)
+ static public function pretty($mime_type, $fp)
{
$lns = '';
while ($ln = fread($fp, 8192)) {
* Check if the given item is restricted from being shown.
* @return boolean whether or not the item is allowed to be displayed
**/
- function isRestricted($item)
+ static public function isRestricted($item)
{
global $conf, $perms, $sourceroots, $sourceroot;
static $restricted;
/**
* Build Chora's list of menu items.
*/
- function getMenu($returnType = 'object')
+ static public function getMenu($returnType = 'object')
{
require_once 'Horde/Menu.php';
/**
*/
- function getFileViews()
+ static public function getFileViews()
{
global $where;
/**
*/
- function formatLogMessage($log)
+ static public function formatLogMessage($log)
{
global $conf;
*
* @return array An array of linked tags.
*/
- function getTags($lg, $where)
+ static public function getTags($lg, $where)
{
$tags = array();
+
foreach ($lg->querySymbolicBranches() as $symb => $bra) {
$tags[] = '<a href="' . Chora::url('', $where, array('onb' => $bra)) . '">'. htmlspecialchars($symb) . '</a>';
}
+
if ($lg->tags) {
foreach ($lg->tags as $tag) {
$tags[] = htmlspecialchars($tag);
}
}
+
return $tags;
}
*
* @return array An 2-member array - branch name and branch revision.
*/
- function getBranch($fl, $rev)
+ static public function getBranch($fl, $rev)
{
$branchName = '';
$rev_ob = $fl->rev->getRevisionObject();
*
* @return string The date formatted pursuant to Horde prefs.
*/
- function formatDate($date)
+ static public function formatDate($date)
{
static $format;