My favorites | Sign in
Project Home Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php

/**
*
* PHP version 5
*
* @category JFusion
* @package JFusionPlugins
* @subpackage Dokuwiki
* @author JFusion Team <webmaster@jfusion.org>
* @copyright 2008 JFusion. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.jfusion.org
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

if (!class_exists('Dokuwiki')) {
require_once dirname(__FILE__) . DS . 'dokuwiki.php';
}

/**
* JFusion Helper Class for Dokuwiki
*
* @category JFusion
* @package JFusionPlugins
* @subpackage Dokuwiki
* @author JFusion Team <webmaster@jfusion.org>
* @copyright 2008 JFusion. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.jfusion.org
*/
class JFusionHelper_dokuwiki
{
/**
* Returns the name for this plugin
*
* @return string
*/
function getJname() {
return 'dokuwiki';
}

/**
* Defines constants required by Dokuwiki
*
* @param $nosession boolean to set the NOSESSION constant; false by default
*/
function defineConstants($nosession = false) {
$share =& Dokuwiki::getInstance($this->getJname());
$conf =& $share->getConf();
$params = JFusionFactory::getParams($this->getJname());
$source_url = $params->get('source_url');
$doku_rel = preg_replace('#(\w{0,10}://)(.*?)/(.*?)#is', '$3', $source_url);
$doku_rel = preg_replace('#//+#', '/', "/$doku_rel/");
if (!defined('DOKU_REL')) {
define('DOKU_REL', $doku_rel);
}
if (!defined('DOKU_URL')) {
define('DOKU_URL', $source_url);
}
if (!defined('DOKU_BASE')) {
define('DOKU_BASE', DOKU_URL);
}
if ($nosession && !defined('NOSESSION')) {
define('NOSESSION', 1);
}
if (!defined('DOKU_COOKIE')) {
define('DOKU_COOKIE', 'DW'.md5(DOKU_REL.(($conf['securecookie'])?$_SERVER['SERVER_PORT']:'')));
}
}

/**
* Retrieves, sets, and returns Dokuwiki's cookie salt
* @return string cookie salt
*/

function getCookieSalt() {
static $dokuwiki_cookie_salt;

if (empty($dokuwiki_cookie_salt)) {
$params = JFusionFactory::getParams($this->getJname());
$source_path = $params->get('source_path');

$share =& Dokuwiki::getInstance($this->getJname());
$conf =& $share->getConf();
$data_dir = (isset($conf['savedir'])) ? $source_path . DS . $conf['savedir'] : $source_path . DS . 'data';

//get the cookie salt file
$saltfile = $data_dir . DS . 'meta' . DS .'_htcookiesalt';
jimport('joomla.filesystem.file');
$dokuwiki_cookie_salt = JFile::read($saltfile);
if(empty($dokuwiki_cookie_salt)){
$dokuwiki_cookie_salt = uniqid(rand(),true);
JFile::write($saltfile,$dokuwiki_cookie_salt);
}
}

return $dokuwiki_cookie_salt;
}

/**
* Retrieves, sets, and returns Dokuwiki's Version
* @return string version
*/

function getVersion($v='version') {
static $dokuwiki_version;

if (empty($dokuwiki_version)) {
$params = JFusionFactory::getParams($this->getJname());
$source_path = $params->get('source_path');

jimport('joomla.filesystem.file');
$file_version = JFile::read($source_path.DS.'VERSION');
$matches = array();
if (preg_match('#([a-z]*)([0-9]*-[0-9]*-[0-9]*)([a-z]*)#is' , $file_version, $matches)) {
list($fullversion, $rc, $version, $sub) = $matches;
$dokuwiki_version['full'] = $fullversion;
$dokuwiki_version['version'] = $version.$rc.$sub;
}
}
if (isset($dokuwiki_version[$v])) {
return $dokuwiki_version[$v];
}
return null;
}

function getConfigPath($path = false) {
static $config_path;

if (empty($config_path)) {
$params =& JFusionFactory::getParams($this->getJname());
$source_path = $params->get('source_path');
$config_path = (empty($path)) ? $source_path : $path;

//make sure the source path ends with a DS
if (substr($path, -1) != DS) {
$config_path .= DS;
}

//standard config path
$config_path .= 'conf' . DS;

//check to see if conf directory is located somewhere else
if (file_exists($source_path . DS . 'inc' . DS . 'preload.php')) {
include_once $source_path . DS . 'inc' . DS . 'preload.php';
if (defined('DOKU_CONF')) {
$config_path = DOKU_CONF;
//make sure we have a ending DS
if (substr($config_path, -1) != DS) {
$config_path .= DS;
}
}
}
}

return $config_path;
}
}

Change log

r2707 by fannoj on Oct 21, 2011   Diff
removed all call-by-refferane
Go to: 
Project members, sign in to write a code review

Older revisions

r2470 by fannoj on Feb 28, 2011   Diff
added: mysql support for dokuwiki
r2462 by fannoj on Feb 14, 2011   Diff
added: dokuversion check so that
cookies are set for old versions of
dokuwiki even they should really
upgrade ...
r2231 by alan.hartless on Jul 4, 2010   Diff
Adding 1.5.x and 1.6.x branches.
All revisions of this file

File info

Size: 5130 bytes, 161 lines
Powered by Google Project Hosting