* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
/* Spawn the file object. */
try {
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
if (!$atdir) {
require CHORA_BASE . '/browsefile.php';
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
if ($atdir) {
require CHORA_BASE . '/browsedir.php';
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
/* If we know we're at a directory, just go to browse.php. */
if ($atdir) {
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
// Exit if cvsgraph isn't active or it's not supported.
if (empty($conf['paths']['cvsgraph']) || !$VC->hasFeature('branches')) {
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
/* Spawn the repository and file objects */
try {
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
// TODO - This currently doesn't work.
Chora::fatal('History display is currently broken', '500 Internal Server Error');
/**
* Chora application API.
*
- * This file defines Chora's external API interface. Other applications can
- * interact with Chora through this API.
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Chora through this API.
+ *
+ * Copyright 2010 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.
*
* @package Chora
*/
+
+if (!defined('CHORA_BASE')) {
+ define('CHORA_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(CHORA_BASE . '/config/horde.local.php')) {
+ include CHORA_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', CHORA_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
class Chora_Application extends Horde_Registry_Application
{
/**
public $version = 'H4 (3.0-git)';
/**
+ * TODO
+ */
+ static protected $perms = array();
+
+ /**
+ * Initialization function.
+ *
+ * Global variables defined:
+ * $sourceroots
+ */
+ protected function _init()
+ {
+ global $conf;
+ global $acts, $defaultActs, $where, $atdir, $fullname, $sourceroot;
+
+ try {
+ $GLOBALS['sourceroots'] = Horde::loadConfiguration('sourceroots.php', 'sourceroots');
+ } catch (Horde_Exception $e) {
+ $GLOBALS['notification']->push($e);
+ $GLOBALS['sourceroots'] = array();
+ }
+ $sourceroots = Chora::sourceroots();
+
+ /**
+ * Variables we wish to propagate across web pages
+ * sbt = Sort By Type (name, age, author, etc)
+ * ha = Hide Attic Files
+ * ord = Sort order
+ *
+ * Obviously, defaults go into $defaultActs :)
+ * 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,
+ 'onb' => 0,
+ 'rev' => 0,
+ );
+
+ /* Use the last sourceroot used as the default value if the user has
+ * that preference. */
+ $last_sourceroot = $GLOBALS['prefs']->getValue('last_sourceroot')
+ ? $GLOBALS['prefs']->getValue('last_sourceroot')
+ : null;
+
+ if (!empty($last_sourceroot) &&
+ !empty($sourceroots[$last_sourceroot]) &&
+ is_array($sourceroots[$last_sourceroot])) {
+ $defaultActs['rt'] = $last_sourceroot;
+ } else {
+ foreach ($sourceroots as $key => $val) {
+ if (isset($val['default']) || !isset($defaultActs['rt'])) {
+ $defaultActs['rt'] = $key;
+ }
+ }
+ }
+
+ $acts = array();
+ if (!isset($defaultActs['rt'])) {
+ Chora::fatal(_("No repositories found."));
+ return;
+ }
+
+ /* See if any have been passed as GET variables, and if so, assign
+ * them into the acts array. */
+ foreach ($defaultActs as $key => $default) {
+ $acts[$key] = Horde_Util::getFormData($key, $default);
+ }
+
+ if (!isset($sourceroots[$acts['rt']])) {
+ Chora::fatal(_("Malformed URL"), '400 Bad Request');
+ }
+
+ $sourcerootopts = $sourceroots[$acts['rt']];
+ $sourceroot = $acts['rt'];
+
+ // Cache.
+ if (empty($conf['caching'])) {
+ $cache = null;
+ } else {
+ $cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+ }
+
+ $conf['paths']['temp'] = Horde::getTempDir();
+
+ try {
+ $GLOBALS['VC'] = Horde_Vcs::factory(Horde_String::ucfirst($sourcerootopts['type']),
+ array('cache' => $cache,
+ 'sourceroot' => $sourcerootopts['location'],
+ 'paths' => $conf['paths'],
+ 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '',
+ 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
+ } catch (Horde_Vcs_Exception $e) {
+ Chora::fatal($e);
+ }
+
+ $conf['paths']['sourceroot'] = $sourcerootopts['location'];
+ $conf['paths']['cvsusers'] = $sourcerootopts['location'] . '/' . (isset($sourcerootopts['cvsusers']) ? $sourcerootopts['cvsusers'] : '');
+ $conf['paths']['introText'] = CHORA_BASE . '/config/' . (isset($sourcerootopts['intro']) ? $sourcerootopts['intro'] : '');
+ $conf['options']['introTitle'] = isset($sourcerootopts['title']) ? $sourcerootopts['title'] : '';
+ $conf['options']['sourceRootName'] = $sourcerootopts['name'];
+
+ $where = Horde_Util::getFormData('f', '/');
+
+ /* Location relative to the sourceroot. */
+ $where = preg_replace(array('|^/|', '|\.\.|'), '', $where);
+
+ /* Store last repository viewed */
+ $GLOBALS['prefs']->setValue('last_sourceroot', $acts['rt']);
+
+ $fullname = $sourcerootopts['location'] . (substr($sourcerootopts['location'], -1) == '/' ? '' : '/') . $where;
+
+ if ($sourcerootopts['type'] == 'cvs') {
+ $fullname = preg_replace('|/$|', '', $fullname);
+ $atdir = @is_dir($fullname);
+ } else {
+ $atdir = !$where || (substr($where, -1) == '/');
+ }
+ $where = preg_replace('|/$|', '', $where);
+
+ 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');
+ }
+
+ if (Chora::isRestricted($where)) {
+ Chora::fatal(sprintf(_("%s: Forbidden by server configuration"), $where), '403 Forbidden');
+ }
+ }
+
+ /**
* Returns a list of available permissions.
*
* @return array An array describing all available permissions.
*/
public function perms()
{
- static $perms = array();
-
- if (!empty($perms)) {
- return $perms;
+ if (!empty(self::$_perms)) {
+ return self::$_perms;
}
require_once dirname(__FILE__) . '/../config/sourceroots.php';
- $perms['tree']['chora']['sourceroots'] = false;
- $perms['title']['chora:sourceroots'] = _("Repositories");
+ self::$_perms['tree']['chora']['sourceroots'] = false;
+ self::$_perms['title']['chora:sourceroots'] = _("Repositories");
// Run through every source repository
foreach ($sourceroots as $sourceroot => $srconfig) {
- $perms['tree']['chora']['sourceroots'][$sourceroot] = false;
- $perms['title']['chora:sourceroots:' . $sourceroot] = $srconfig['name'];
+ self::$_perms['tree']['chora']['sourceroots'][$sourceroot] = false;
+ self::$_perms['title']['chora:sourceroots:' . $sourceroot] = $srconfig['name'];
}
- return $perms;
+ return self::$_perms;
}
/**
function _buildTree(&$tree, $indent = 0, $parent = null)
{
define('CHORA_ERROR_HANDLER', true);
- require_once dirname(__FILE__) . '/../base.php';
$arr = array();
asort($GLOBALS['sourceroots']);
static public $fdcache;
/**
- * Initialize global variables and objects.
- */
- static public function initialize()
- {
- global $acts, $defaultActs, $where, $atdir, $fullname, $sourceroot;
-
- try {
- $GLOBALS['sourceroots'] = Horde::loadConfiguration('sourceroots.php', 'sourceroots');
- } catch (Horde_Exception $e) {
- $GLOBALS['notification']->push($e);
- $GLOBALS['sourceroots'] = array();
- }
- $sourceroots = self::sourceroots();
-
- /**
- * Variables we wish to propagate across web pages
- * sbt = Sort By Type (name, age, author, etc)
- * ha = Hide Attic Files
- * ord = Sort order
- *
- * Obviously, defaults go into $defaultActs :)
- * TODO: defaults of 1 will not get propagated correctly - avsm
- * XXX: Rewrite this propagation code, since it sucks - avsm
- */
- $defaultActs = array(
- 'sbt' => constant($GLOBALS['conf']['options']['defaultsort']),
- 'sa' => 0,
- 'ord' => Horde_Vcs::SORT_ASCENDING,
- 'ws' => 1,
- 'onb' => 0,
- 'rev' => 0,
- );
-
- /* Use the last sourceroot used as the default value if the user has
- * that preference. */
- $last_sourceroot = $GLOBALS['prefs']->getValue('last_sourceroot')
- ? $GLOBALS['prefs']->getValue('last_sourceroot')
- : null;
-
- if (!empty($last_sourceroot) &&
- !empty($sourceroots[$last_sourceroot]) &&
- is_array($sourceroots[$last_sourceroot])) {
- $defaultActs['rt'] = $last_sourceroot;
- } else {
- foreach ($sourceroots as $key => $val) {
- if (isset($val['default']) || !isset($defaultActs['rt'])) {
- $defaultActs['rt'] = $key;
- }
- }
- }
-
- $acts = array();
- if (!isset($defaultActs['rt'])) {
- self::fatal(_("No repositories found."));
- return;
- }
-
- /* See if any have been passed as GET variables, and if so, assign
- * them into the acts array. */
- foreach ($defaultActs as $key => $default) {
- $acts[$key] = Horde_Util::getFormData($key, $default);
- }
-
- if (!isset($sourceroots[$acts['rt']])) {
- self::fatal(_("Malformed URL"), '400 Bad Request');
- }
-
- $sourcerootopts = $sourceroots[$acts['rt']];
- $sourceroot = $acts['rt'];
-
- // Cache.
- if (empty($GLOBALS['conf']['caching'])) {
- $cache = null;
- } else {
- $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
- }
-
- $GLOBALS['conf']['paths']['temp'] = Horde::getTempDir();
-
- try {
- $GLOBALS['VC'] = Horde_Vcs::factory(Horde_String::ucfirst($sourcerootopts['type']),
- array('cache' => $cache,
- 'sourceroot' => $sourcerootopts['location'],
- 'paths' => $GLOBALS['conf']['paths'],
- 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '',
- 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
- } catch (Horde_Vcs_Exception $e) {
- self::fatal($e);
- }
-
- $GLOBALS['conf']['paths']['sourceroot'] = $sourcerootopts['location'];
- $GLOBALS['conf']['paths']['cvsusers'] = $sourcerootopts['location'] . '/' . (isset($sourcerootopts['cvsusers']) ? $sourcerootopts['cvsusers'] : '');
- $GLOBALS['conf']['paths']['introText'] = CHORA_BASE . '/config/' . (isset($sourcerootopts['intro']) ? $sourcerootopts['intro'] : '');
- $GLOBALS['conf']['options']['introTitle'] = isset($sourcerootopts['title']) ? $sourcerootopts['title'] : '';
- $GLOBALS['conf']['options']['sourceRootName'] = $sourcerootopts['name'];
-
- $where = Horde_Util::getFormData('f', '/');
-
- /* Location relative to the sourceroot. */
- $where = preg_replace(array('|^/|', '|\.\.|'), '', $where);
-
- /* Store last repository viewed */
- $GLOBALS['prefs']->setValue('last_sourceroot', $acts['rt']);
-
- $fullname = $sourcerootopts['location'] . (substr($sourcerootopts['location'], -1) == '/' ? '' : '/') . $where;
-
- if ($sourcerootopts['type'] == 'cvs') {
- $fullname = preg_replace('|/$|', '', $fullname);
- $atdir = @is_dir($fullname);
- } else {
- $atdir = !$where || (substr($where, -1) == '/');
- }
- $where = preg_replace('|/$|', '', $where);
-
- if (($sourcerootopts['type'] == 'cvs') &&
- !@is_dir($sourcerootopts['location'])) {
- self::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');
- }
-
- if (self::isRestricted($where)) {
- self::fatal(sprintf(_("%s: Forbidden by server configuration"), $where), '403 Forbidden');
- }
- }
-
- /**
* Create the breadcrumb directory listing.
*
* @param string $where The current filepath.
+++ /dev/null
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 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.
- *
- * @package Chora
- */
-
-if (!defined('CHORA_BASE')) {
- define('CHORA_BASE', dirname(__FILE__) . '/..');
-}
-
-if (!defined('HORDE_BASE')) {
- /* If horde does not live directly under the app directory, the HORDE_BASE
- * constant should be defined in config/horde.local.php. */
- if (file_exists(CHORA_BASE . '/config/horde.local.php')) {
- include CHORA_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', CHORA_BASE . '/..');
- }
-}
+++ /dev/null
-<?php
-/**
- * Chora base inclusion file.
- *
- * This file brings in all of the dependencies that every Chora script
- * will need, and sets up objects that all scripts use.
- *
- * The following global variables are used:
- * $no_compress - Controls whether the page should be compressed
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// Load the Horde Framework core.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry
-$registry = Horde_Registry::singleton();
-try {
- $registry->pushApp('chora', array('logintasks' => true));
-} catch (Horde_Exception $e) {
- Horde_Auth::authenticateFailure('chora', $e);
-}
-$conf = &$GLOBALS['conf'];
-define('CHORA_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Initialize objects, path, etc.
-Chora::initialize();
-
-// Start compression.
-if (!Horde_Util::nonInputVar('no_compress')) {
- Horde::compressOutput();
-}
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
// Exit if patchset feature is not available.
if (!$GLOBALS['VC']->hasFeature('patchsets')) {
* @package Chora
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
try {
$fl = $VC->getFileObject($where);