Skip to content

Commit 08a3800

Browse files
committed
Merge branch 'feature/last-steps-for-composer-integration'
2 parents c64b77b + f65e247 commit 08a3800

File tree

9 files changed

+27
-19
lines changed

9 files changed

+27
-19
lines changed

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "opencaching/okapi",
3+
"require": {
4+
"php": ">=5.6.0"
5+
},
6+
"autoload": {
7+
"psr-4": {
8+
"okapi\\": "okapi/"
9+
}
10+
}
11+
}

okapi/Facade.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@
4040

4141
# --------------------
4242

43-
#
44-
# TETODO: We should probably get to the point at which this can be removed.
45-
#
46-
47-
if (!in_array($GLOBALS['rootpath'], explode(PATH_SEPARATOR, get_include_path()))) {
48-
set_include_path(get_include_path().PATH_SEPARATOR.$GLOBALS['rootpath']);
49-
}
50-
5143
require_once __DIR__ . '/autoload.php';
5244
OkapiErrorHandler::$treat_notices_as_errors = true;
5345
Okapi::init_internals();

okapi/Settings.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ private static function load_settings()
235235
# We have to temporarily disable our default error handler.
236236

237237
OkapiErrorHandler::disable();
238-
require_once __DIR__ . '/../okapi_settings.php';
238+
$okapiSettings = __DIR__ . '/../okapi_settings.php';
239+
if (!file_exists($okapiSettings)) {
240+
$okapiSettings = __DIR__ . '/../../../../okapi_settings.php';
241+
}
242+
require_once $okapiSettings;
239243
$ref = get_okapi_settings();
240244
OkapiErrorHandler::reenable();
241245

@@ -328,7 +332,7 @@ public static function default_gettext_init($langprefs)
328332
putenv("LC_ALL=$locale");
329333
setlocale(LC_ALL, $locale);
330334
setlocale(LC_NUMERIC, "POSIX"); # We don't want *this one* to get out of control.
331-
bindtextdomain("okapi_messages", $GLOBALS['rootpath'].'okapi/locale');
335+
bindtextdomain("okapi_messages", __DIR__ . '/locale');
332336
return $locale;
333337
}
334338

okapi/core/OkapiServiceRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function docs($service_name)
9696
throw new \Exception();
9797
}
9898
try {
99-
return file_get_contents("$service_name/docs.xml", true);
99+
return file_get_contents(__DIR__.'/../'.$service_name. '/docs.xml', true);
100100
} catch (\Exception $e) {
101101
throw new \Exception("Missing documentation file: $service_name.xml");
102102
}

okapi/index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
use okapi\core\Okapi;
2323
use okapi\core\OkapiErrorHandler;
2424

25-
$GLOBALS['rootpath'] = __DIR__.'/../';
25+
# When deployed via composer, the rootpath is already set.
26+
if (!isset($GLOBALS['rootpath'])) {
27+
$GLOBALS['rootpath'] = __DIR__.'/../';
28+
}
2629

2730
require_once __DIR__ . '/autoload.php';
2831

okapi/services/apiref/method_index/WebService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private static function generateCacheKey() {
7171

7272
return (
7373
"api_ref/method_index#dev#".
74-
self::getDirModDateRecursive($GLOBALS['rootpath']."okapi/services")
74+
self::getDirModDateRecursive(__DIR__. '/../../../../okapi/services')
7575
);
7676
}
7777
}

okapi/services/attrs/AttrHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function refresh_now()
4242
{
4343
try
4444
{
45-
$path = $GLOBALS['rootpath']."okapi/services/attrs/attribute-definitions.xml";
45+
$path = __DIR__ . '/../../../okapi/services/attrs/attribute-definitions.xml';
4646
$xml = file_get_contents($path);
4747
self::refresh_from_string($xml);
4848
}

okapi/services/caches/map/TileRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static function get_image($name, $opacity=1, $brightness=0,
126126
{
127127
# Miss again (or error decoding). Read the image from PNG.
128128

129-
$locmem_cache[$key] = imagecreatefrompng($GLOBALS['rootpath']."okapi/static/tilemap/$name.png");
129+
$locmem_cache[$key] = imagecreatefrompng(__DIR__."/../../../../okapi/static/tilemap/$name.png");
130130

131131
# Apply all wanted effects.
132132

@@ -357,7 +357,7 @@ private function get_caption($cache_id, $name_crc)
357357
# Split the name into a couple of lines.
358358

359359
//$font = $GLOBALS['rootpath'].'util.sec/bt.ttf';
360-
$font = $GLOBALS['rootpath'].'okapi/static/tilemap/tahoma.ttf';
360+
$font = __DIR__.'/../../../../okapi/static/tilemap/tahoma.ttf';
361361
$size = 25;
362362
$lines = explode("\n", self::wordwrap($font, $size, 64*4 - 6*2, $name));
363363

okapi/services/logs/submit/WebService.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,9 @@ private static function _call(OkapiRequest $request)
312312
# NOTICE: We are including EXTERNAL OCDE libraries here! This
313313
# code does not belong to OKAPI!
314314

315-
if (Settings::get('OC_BRANCH') == 'oc.de')
315+
if (Settings::get('OC_BRANCH') === 'oc.de')
316316
{
317-
$opt['rootpath'] = $GLOBALS['rootpath'];
318317
$opt['html_purifier'] = Settings::get('OCDE_HTML_PURIFIER_SETTINGS');
319-
require_once $GLOBALS['rootpath'] . 'lib2/OcHTMLPurifier.class.php';
320318

321319
$purifier = new \OcHTMLPurifier($opt);
322320
$formatted_comment = $purifier->purify($formatted_comment);

0 commit comments

Comments
 (0)