Browse the code
| Differences between 158 and 159 on /. | |
|---|---|
| Number of edited files: | 48 (4 added, 0 deleted and 44 modified) |
| Author: | xbright |
| Log message: | * Added DrawSVGChart and 3 charts for each projects * Added a print.css * Deleted like() in inc/classes/db.php, select() is now better * Added documentation for inc/classes/session.php * Added user management (change level) in administration * Added a maximum file number in the cache * Added full-support for OpenForge 0.1 (projects and users information retrieval) * Added external search (based on OpenForge 0.1) (and internal search now working) * Ignore some errors (ugly work-around!) * Deleted a lot of license in the default list * Popularity contest is now resetted each months * Added projects.commit to handle all commits * Edited post-commit.php (now using sql to store *all* commits) * Now showing commits in the timeline and provide a RSS/ATOM feed * Removed translation from project module * Started to replace links with buttons to delete content on the forge (security reason) * Fixed a bizarre bug in inc/modules/project/views/bug.php related to bugs sorting (and the fix is bizarre too) * Fixed a bug in the news feed of a project * Worked on the SVN browser (diffs, feed, new *FASTER* way to send commands...) * Typo in account registering * Removed sended mail with the password after registration (security reason) * The i18n function now allow errors and can handle a decimal as a string if the given value is not decimal * Edited the SQL schema * Added openforge, cache-max-files, and need-validate modifications to the INSTALL * Maybe one or two forgoten bug fixes * Yes, I know, this is a really (too) *big* commit message |
| Date: | 2008-09-05 12:30:11 |
| Old | New | Code |
|---|---|---|
| 12 | 12 | |
| 13 | 13 |
RewriteCond %{REQUEST_URI} !^/public/(.*)?$
|
| 14 | 14 |
RewriteCond %{REQUEST_URI} !^/inc/templates/([a-z-]+)\.css?$
|
| 15 |
RewriteCond %{REQUEST_URI} !^/robots.txt?$
| |
| 15 | 16 |
RewriteRule ^(.*)$ index.php [QSA,L] |
| 16 | 17 | |
| 17 | 18 |
php_flag magic_quotes_gpc Off |
| 18 | 19 |
| Old | New | Code |
|---|---|---|
| 93 | 93 | |
| 94 | 94 |
INSERT INTO `config` (`group`, `field`, `value`, `text`) VALUES |
| 95 | 95 |
('global', 'mailfrom', 'MyForgeName <mail@domain.net>', 'The FROM and REPLYTO headers of sended mail.'),
|
| 96 |
('global', 'cache-max-files', '2000', 'The maximum files number for the cache.'),
| |
| 96 | 97 | |
| 97 | 98 |
('fenrir', 'xmlrpc-host', 'localhost', 'The host to contact the bot.'),
|
| 98 | 99 |
('fenrir', 'xmlrpc-port', '8000', 'The port to contact the bot.'),
|
| 106 | 107 |
('jabber', 'password', 'password', 'The password of the bot.'),
|
| 107 | 108 |
('jabber', 'nickname', 'nickname', 'The nickname of the bot.'),
|
| 108 | 109 | |
| 109 |
('projects', 'needvalidate', 'true', 'true or false if you want to validate all new projects.'),
| |
| 110 |
('openforge', 'esearch-active', 'true', 'true or false if you want to active external search.'),
| |
| 111 |
('openforge', 'esearch-servers', '', 'A list of external servers, separated by a ";".'),
| |
| 112 | ||
| 113 |
('projects', 'need-validate', 'true', 'true or false if you want to validate all new projects.'),
| |
| 110 | 114 |
('projects', 'allow-adding', 'true', 'true or false if you want to disable projects adding.'),
|
| 111 | 115 |
('projects', 'allow-donation', 'true', 'true or false if you want to disable projects donation.'),
|
| 112 | 116 | |
| 113 | 117 |
| Old | New | Code |
|---|---|---|
| 9 | 9 |
* http://codingteam.codingteam.net |
| 10 | 10 | |
| 11 | 11 |
SVN Browse: |
| 12 |
* http://svn.codingteam.net/code/codingteam | |
| 13 |
* http://www.codingteam.net/project/codingteam/svn | |
| 12 |
* http://svn.codingteam.net/svn/codingteam
| |
| 13 |
* http://www.codingteam.net/project/codingteam/browse | |
| 14 | 14 | |
| 15 | 15 |
Depends: |
| 16 | 16 |
* apache http://www.apache.org (>= 2) |
| 17 | 17 |
| Old | New | Code |
|---|---|---|
| 83 | 83 |
`projectid` int(11) NOT NULL, |
| 84 | 84 |
`userid` int(11) NOT NULL, |
| 85 | 85 |
`role` enum('projectleader','graphicdesigner','developer','translater','packager','contributer') collate utf8_bin NOT NULL,
|
| 86 |
UNIQUE KEY `admin` (`projectid`,`userid`,`role`) | |
| 86 |
UNIQUE KEY `admin` (`projectid`,`userid`)
| |
| 87 | 87 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; |
| 88 | 88 | |
| 89 | 89 |
-- |
| 155 | 155 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; |
| 156 | 156 | |
| 157 | 157 |
-- |
| 158 |
-- projects_commits | |
| 159 |
-- | |
| 160 | ||
| 161 |
CREATE TABLE IF NOT EXISTS `projects_commits` ( | |
| 162 |
`id` int(11) NOT NULL auto_increment, | |
| 163 |
`projectid` int(11) NOT NULL, | |
| 164 |
`prev_rev` int(11) NOT NULL, | |
| 165 |
`new_rev` int(11) NOT NULL, | |
| 166 |
`log` text collate utf8_bin NOT NULL, | |
| 167 |
`author` tinytext collate utf8_bin NOT NULL, | |
| 168 |
`datetime` datetime NOT NULL, | |
| 169 |
PRIMARY KEY (`id`) | |
| 170 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; | |
| 171 | ||
| 172 |
-- | |
| 158 | 173 |
-- projects_doc |
| 159 | 174 |
-- |
| 160 | 175 | |
| 291 | 306 |
`version` varchar(15) COLLATE utf8_bin NOT NULL, |
| 292 | 307 |
`status` enum('planned','development','testing','alpha','beta','stable','abandonned') COLLATE utf8_bin NOT NULL,
|
| 293 | 308 |
PRIMARY KEY (`id`), |
| 294 |
UNIQUE KEY `version` (`projectid`,`version`,`status`) | |
| 309 |
UNIQUE KEY `version` (`projectid`,`version`)
| |
| 295 | 310 |
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_bin; |
| 296 | 311 | |
| 297 | 312 |
-- |
| 378 | 393 |
ADD CONSTRAINT `constr_projects_forum_postid` FOREIGN KEY (postid) REFERENCES projects_forum(id) ON DELETE CASCADE; |
| 379 | 394 | |
| 380 | 395 |
ALTER TABLE `projects_jabber` |
| 381 |
ADD CONSTRAINT `constr_projects_projectid9` FOREIGN KEY (projectid) REFERENCES projects(id) ON DELETE CASCADE; | |
| 396 |
ADD CONSTRAINT `constr_projects_projectid9` FOREIGN KEY (projectid) REFERENCES projects(id) ON DELETE CASCADE; | |
| 397 | ||
| 398 |
ALTER TABLE `projects_commits` | |
| 399 |
ADD CONSTRAINT `constr_projects_projectid10` FOREIGN KEY (projectid) REFERENCES projects(id) ON DELETE CASCADE; | |
| 382 | 400 |
| Old | New | Code |
|---|---|---|
| 23 | 23 |
* This file contains the Database class |
| 24 | 24 |
* |
| 25 | 25 |
* Connect to MySQL or PostgreSQL. |
| 26 |
* Functions for insert, update, delete, select and select with LIKE rather than `=`. | |
| 26 |
* Functions for insert, update, delete, select.
| |
| 27 | 27 |
*/ |
| 28 | 28 | |
| 29 | 29 | |
| 34 | 34 |
{
|
| 35 | 35 |
private $type, $hostname, $database, $username, $password, $error; |
| 36 | 36 | |
| 37 |
function __construct($type, $hostname, $database, $username, $password, $error) | |
| 37 |
function __construct($type, $hostname, $database, $username, $password, $error=FALSE)
| |
| 38 | 38 |
{
|
| 39 | 39 |
$this->error = $error; |
| 40 | 40 | |
| 54 | 54 |
break; |
| 55 | 55 | |
| 56 | 56 |
default: |
| 57 |
exit('Error: database type not supported, aborting.');
| |
| 57 |
exit('Error: database type not supported by CodingTeam, aborting.');
| |
| 58 | 58 |
} |
| 59 | 59 |
} |
| 60 | 60 |
catch (PDOException $e) |
| 61 | 61 |
{
|
| 62 |
$this->error->displayError('The link to the database could not be etablished.<br />'.$e->getMessage(), 2);
| |
| 62 |
if ($error)
| |
| 63 |
$this->error->displayError('The link to the database could not be etablished.<br />'.$e->getMessage(), 2);
| |
| 63 | 64 |
} |
| 64 | 65 |
} |
| 65 | 66 | |
| 71 | 72 |
* @param $table |
| 72 | 73 |
* The table in the database. |
| 73 | 74 |
* @param $where |
| 74 |
* An array like 'field' => 'value'. | |
| 75 |
* An array like 'field' => 'value' (can be 'field => array('value', 'LIKE')).
| |
| 75 | 76 |
* @param $what (optional) |
| 76 | 77 |
* The list of wished field's value. |
| 77 | 78 |
* @param $optional (optional) |
| 78 | 79 |
* SQL syntax. |
| 80 |
* @param $operator (optional) | |
| 81 |
* A string for the SQL operator (AND or OR). | |
| 79 | 82 |
* @return |
| 80 | 83 |
* The fetched results. |
| 81 | 84 |
*/ |
| 82 |
function select($_table, $where, $what='*', $optional='') | |
| 85 |
function select($_table, $where, $what='*', $optional='', $operator='AND')
| |
| 83 | 86 |
{
|
| 84 | 87 |
// Trying to select data |
| 85 | 88 |
try |
| 103 | 106 |
if(is_array($where)) |
| 104 | 107 |
{
|
| 105 | 108 |
$sql1 .= 'WHERE '; |
| 106 |
foreach($where as $key => $value) | |
| 107 |
{
| |
| 108 |
$sql2[] = '`'.$key.'`= '.$this->dbclass->quote($value); | |
| 109 |
$paramArray[] = $value; | |
| 110 |
} | |
| 111 |
} | |
| 112 | 109 | |
| 113 |
$rs = $this->dbclass->prepare($sql1.(count($paramArray) ? ' '.join(' AND ',$sql2) : '').' '.$optional);
| |
| 114 | ||
| 115 |
if($rs->execute($paramArray)) | |
| 116 |
return $rs->fetchAll(PDO::FETCH_ASSOC); | |
| 117 |
$err = $rs->errorInfo(); | |
| 118 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 119 |
} | |
| 120 |
catch (PDOException $e) | |
| 121 |
{
| |
| 122 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 123 |
} | |
| 124 |
} | |
| 125 | ||
| 126 | ||
| 127 |
/** | |
| 128 |
* Like | |
| 129 |
* | |
| 130 |
* Treatment for a SELECT request with LIKE rather than `=`. | |
| 131 |
* @param $table | |
| 132 |
* The table in the database. | |
| 133 |
* @param $where | |
| 134 |
* An array like 'field' => 'value'. | |
| 135 |
* @param $what (optional) | |
| 136 |
* The list of wished field's value. | |
| 137 |
* @param $optional (optional) | |
| 138 |
* SQL syntax. | |
| 139 |
* @param $operator (optional) | |
| 140 |
* `AND` or `OR`. | |
| 141 |
* @return | |
| 142 |
* The fetched results. | |
| 143 |
*/ | |
| 144 |
function like($table, $where, $what='*', $optional='', $operator='AND') | |
| 145 |
{
| |
| 146 |
// Trying to select data | |
| 147 |
try | |
| 148 |
{
| |
| 149 |
$sql1 = 'SELECT '.$what.' FROM '.$table.' '; | |
| 150 |
$sql2 = array(); | |
| 151 |
$paramArray = array(); | |
| 152 |
if(is_array($where)) | |
| 153 |
{
| |
| 154 |
$sql1 .= 'WHERE '; | |
| 155 |
foreach($where as $key => $value) | |
| 110 |
foreach ($where as $key => $value) | |
| 156 | 111 |
{
|
| 157 |
$sql2[] = ''.$key.' LIKE "%'.$value.'%"'; | |
| 158 |
$paramArray[] = $value; | |
| 112 |
if (!is_array($value))
| |
| 113 |
{
| |
| 114 |
$sql2[] = '`'.$key.'` = '.$this->dbclass->quote($value); | |
| 115 |
$paramArray[] = $value; | |
| 116 |
} | |
| 117 |
elseif ($value[1] == 'LIKE') | |
| 118 |
{
| |
| 119 |
$sql2[] = '`'.$key.'` LIKE '.$this->dbclass->quote('%'.$value[0].'%');
| |
| 120 |
$paramArray[] = $value[0]; | |
| 121 |
} | |
| 159 | 122 |
} |
| 160 | 123 |
} |
| 161 | 124 | |
| 162 |
print_r($sql1.(count($paramArray) ? ' '.join(' '.$operator.' ',$sql2) : '').' '.$optional);
| |
| 125 |
$sqlline = $sql1.(count($paramArray) ? ' '.join(' '.$operator.' ',$sql2) : '').' '.$optional;
| |
| 126 |
$rs = $this->dbclass->prepare($sqlline); | |
| 163 | 127 | |
| 164 |
$rs = $this->dbclass->prepare($sql1.(count($paramArray) ? ' '.join(' '.$operator.' ',$sql2) : '').' '.$optional);
| |
| 165 | 128 |
if($rs->execute($paramArray)) |
| 166 | 129 |
return $rs->fetchAll(PDO::FETCH_ASSOC); |
| 130 | ||
| 167 | 131 |
$err = $rs->errorInfo(); |
| 168 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 132 |
if ($error)
| |
| 133 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 169 | 134 |
} |
| 170 | 135 |
catch (PDOException $e) |
| 171 | 136 |
{
|
| 172 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 137 |
if ($error)
| |
| 138 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 173 | 139 |
} |
| 174 | 140 |
} |
| 175 | 141 | |
| 203 | 169 | |
| 204 | 170 |
if($rs->execute(array_values($data))) |
| 205 | 171 |
return $this->dbclass->lastInsertId(); |
| 206 |
else {
| |
| 172 |
else
| |
| 173 |
{
| |
| 207 | 174 |
$err = $rs->errorInfo(); |
| 208 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 209 |
return FALSE; | |
| 175 | ||
| 176 |
if ($error)
| |
| 177 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 210 | 178 |
} |
| 211 | 179 | |
| 212 | 180 |
} |
| 213 | 181 |
catch (PDOException $e) |
| 214 | 182 |
{
|
| 215 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 183 |
if ($error)
| |
| 184 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 216 | 185 |
} |
| 217 | 186 |
} |
| 218 | 187 | |
| 266 | 235 |
} |
| 267 | 236 |
catch (PDOException $e) |
| 268 | 237 |
{
|
| 269 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 238 |
if ($error)
| |
| 239 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 270 | 240 |
} |
| 271 | 241 |
} |
| 272 | 242 | |
| 302 | 272 |
return TRUE; |
| 303 | 273 |
|
| 304 | 274 |
$err = $rs->errorInfo(); |
| 305 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 275 |
if ($error)
| |
| 276 |
$this->error->displayError('An error occured.<br />'.$err[2], 1);
| |
| 306 | 277 |
} |
| 307 | 278 |
catch (PDOException $e) |
| 308 | 279 |
{
|
| 309 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 280 |
if ($error)
| |
| 281 |
$this->error->displayError('The request could not be finalized.<br />'.$e->getMessage(), 1);
| |
| 310 | 282 |
} |
| 311 | 283 |
} |
| 312 | 284 | |
| 336 | 308 |
return $postval; |
| 337 | 309 |
} |
| 338 | 310 |
} |
| 339 |
?> | |
| 311 |
?> | |
| 340 | 312 |
| Old | New | Code |
|---|---|---|
| 59 | 59 |
*/ |
| 60 | 60 |
function displayError ($error, $status, $http='') |
| 61 | 61 |
{
|
| 62 |
// In this file, if an external server (for OpenForge extern search) is not | |
| 63 |
// online, we get an ugly warning, just ignore it (that's not bad, that's just | |
| 64 |
// a work-around: WARNING shouldn't be blocking, but our class make them so). | |
| 65 |
if ($error[0] == 2 && $error[2] == $this->basedir.'/inc/modules/search/views/default.php') | |
| 66 |
return FALSE; | |
| 67 | ||
| 68 |
// I don't understand PDO. Sometimes it works, sometimes not. Without any good reason. | |
| 69 |
// But I don't want to annoy end-users with that. And I'm investigating this bug. But I | |
| 70 |
// just don't find another way to "fix" that. It's ugly, yes. You can slap me for that. | |
| 71 |
// Oh, slap me more! I like that! | |
| 72 |
if ($error[0] == 2 && $error[2] == $this->basedir.'/inc/classes/db.php') | |
| 73 |
return FALSE; | |
| 74 | ||
| 62 | 75 |
if (!empty($http)) |
| 63 | 76 |
Header('HTTP/1.0 '.$http);
|
| 64 | 77 | |
| 65 | 78 |
| Old | New | Code |
|---|---|---|
| 22 | 22 |
* @file |
| 23 | 23 |
* This file contains the Session class |
| 24 | 24 |
* |
| 25 |
* Init session, (auto) log-in, log-out and test status | |
| 25 |
* Init session, (auto) log-in, log-out and status-testing.
| |
| 26 | 26 |
*/ |
| 27 | 27 | |
| 28 | 28 | |
| 39 | 39 |
$this->error = $error; |
| 40 | 40 |
} |
| 41 | 41 | |
| 42 | ||
| 43 |
/** | |
| 44 |
* Init | |
| 45 |
* | |
| 46 |
* Create the session for this user. | |
| 47 |
* @param $ip | |
| 48 |
* The IP address of this user. | |
| 49 |
*/ | |
| 42 | 50 |
function init($ip) |
| 43 | 51 |
{
|
| 44 | 52 |
// Construct session |
| 45 | 53 |
session_start(); |
| 46 | 54 |
$_SESSION['ip'] = $ip; |
| 55 | ||
| 47 | 56 |
if (empty($_SESSION['alea'])) |
| 48 | 57 |
$_SESSION['alea'] = rand(42, 1337); |
| 58 | ||
| 49 | 59 |
if (empty($_SESSION['captcha'])) |
| 50 | 60 |
$_SESSION['captcha'] = generateUniqueID(FALSE); |
| 51 | 61 | |
| 54 | 64 |
$this->autologin(); |
| 55 | 65 |
} |
| 56 | 66 | |
| 67 | ||
| 68 |
/** | |
| 69 |
* Log out | |
| 70 |
* | |
| 71 |
* Log out a registered user and destroy his session. | |
| 72 |
*/ | |
| 57 | 73 |
function logout() |
| 58 | 74 |
{
|
| 59 | 75 |
// Destroy current session and cookie if exist |
| 62 | 78 |
if (isset($_COOKIE['ctcookieautoc'])) |
| 63 | 79 |
$this->unsetcookie('ctcookieautoc');
|
| 64 | 80 | |
| 81 |
// Go at the home page | |
| 65 | 82 |
global $baseurl; |
| 66 | 83 |
Header('Location: '.$baseurl);
|
| 67 | 84 |
exit(); |
| 68 | 85 |
} |
| 69 |
| |
| 86 | ||
| 87 | ||
| 88 |
/**
| |
| 89 |
* Auto-login | |
| 90 |
* | |
| 91 |
* Log in a registered user with the cookie. | |
| 92 |
*/ | |
| 70 | 93 |
function autologin() |
| 71 | 94 |
{
|
| 72 | 95 |
if (isset($_COOKIE['ctcookieautoc'])) |
| 117 | 140 |
} |
| 118 | 141 |
} |
| 119 | 142 |
} |
| 120 |
| |
| 143 | ||
| 144 | ||
| 145 |
/**
| |
| 146 |
* Unset cookie | |
| 147 |
* | |
| 148 |
* Delete a cookie. | |
| 149 |
* @param $cookie | |
| 150 |
* The cookie to be deleted. | |
| 151 |
*/ | |
| 121 | 152 |
function unsetcookie($cookie) |
| 122 | 153 |
{
|
| 123 | 154 |
// Delete wrong cookie |
| 124 | 155 |
setcookie($cookie, '', 0, '/', '', 0); |
| 125 | 156 |
} |
| 126 |
| |
| 157 | ||
| 158 | ||
| 159 |
/**
| |
| 160 |
* Log in | |
| 161 |
* | |
| 162 |
* Log in a registered user with nickname and password. | |
| 163 |
* @param $nick | |
| 164 |
* The nickname. | |
| 165 |
* @param $pass | |
| 166 |
* The password. | |
| 167 |
* @param $autoconnect | |
| 168 |
* TRUE if you want a cookie to be written. | |
| 169 |
*/ | |
| 127 | 170 |
function login($nick, $pass, $autoconnect=0) |
| 128 | 171 |
{
|
| 129 | 172 |
$hash = sha1($pass); |
| 155 | 198 |
else |
| 156 | 199 |
$this->error->displayError(i18n('Authentification error! Please verify your nickname (case-sensitive).'), 0);
|
| 157 | 200 |
} |
| 158 |
| |
| 201 | ||
| 202 | ||
| 203 |
/**
| |
| 204 |
* Is logged? | |
| 205 |
* | |
| 206 |
* Return TRUE if a user is currently logged. | |
| 207 |
* @return | |
| 208 |
* A boolean. | |
| 209 |
*/ | |
| 159 | 210 |
function isLogged() |
| 160 | 211 |
{
|
| 161 | 212 |
//Check if the user is logged |
| 162 | 213 |
| Old | New | Code |
|---|---|---|
| 20 | 20 | |
| 21 | 21 |
/** |
| 22 | 22 |
* @file |
| 23 |
* Experimental SVG graphs | |
| 23 |
* This file contains a class that calls DrawSVGChart
| |
| 24 | 24 |
*/ |
| 25 | 25 | |
| 26 | 26 | |
| 39 | 39 |
$this->page = $page; |
| 40 | 40 |
$this->baseurl = $baseurl; |
| 41 | 41 | |
| 42 |
// Start XML output | |
| 43 |
Header('Content-Type: image/svg+xml; charset=utf-8');
| |
| 42 |
$drawsvgchart = getClass('drawsvgchart');
| |
| 44 | 43 | |
| 45 |
// If this is a project | |
| 46 | 44 |
if ($page[2] == 'project') |
| 47 | 45 |
{
|
| 48 | 46 |
// Security test |
| 60 | 58 | |
| 61 | 59 |
// Bugs |
| 62 | 60 |
if ($page[4] == 'bugs') |
| 63 |
$this->generateProjectBugs(); | |
| 61 |
{
| |
| 62 |
$project_versions = getClass('project.versions', $this->database);
| |
| 63 |
$project_bugs = getClass('project.bugs', $this->database);
| |
| 64 | 64 | |
| 65 |
} | |
| 66 |
else | |
| 67 |
exit('Error.');
| |
| 68 |
} | |
| 65 |
$versions = $project_versions->getVersions($this->id);
| |
| 66 |
$bugs_array = array(); | |
| 67 |
$bugs_total = 0; | |
| 69 | 68 | |
| 69 |
foreach ($versions as $version) | |
| 70 |
{
| |
| 71 |
$version = $version['version']; | |
| 72 |
$bugs = $project_bugs->countReports($this->id, $version); | |
| 70 | 73 | |
| 74 |
$buga = $project_bugs->countReportsByStatus($this->id, 'unconfirmed', $version); | |
| 75 |
$bugb = $project_bugs->countReportsByStatus($this->id, 'confirmed', $version); | |
| 76 |
$bugc = $project_bugs->countReportsByStatus($this->id, 'working', $version); | |
| 77 |
$bugd = $project_bugs->countReportsByStatus($this->id, 'needinformations', $version); | |
| 78 |
$buge = $project_bugs->countReportsByStatus($this->id, 'needcontributors', $version); | |
| 79 |
$bugf = $project_bugs->countReportsByStatus($this->id, 'needtests', $version); | |
| 80 |
$bugs_open = $buga + $bugb + $bugc + $bugd + $buge + $bugf; | |
| 71 | 81 | |
| 72 |
function generateProjectBugs() | |
| 73 |
{
| |
| 74 |
$project_versions = getClass('project.versions', $this->database);
| |
| 75 |
$project_bugs = getClass('project.bugs', $this->database);
| |
| 82 |
$bugs_array[0][$version] = $bugs;
| |
| 83 |
$bugs_array[1][$version] = $bugs_open; | |
| 84 |
} | |
| 76 | 85 | |
| 77 |
$versions = $project_versions->getVersions($this->id); | |
| 78 |
$bugs_array = array(); | |
| 79 |
$bugs_total = 0; | |
| 86 |
$legend = array(array('#5276A9', 'reported bugs'),
| |
| 87 |
array('#CD3333', 'open bugs'));
| |
| 88 |
$link = $this->baseurl.'project/'.htmlspecialchars($this->dbname).'/bugs/version/{data}/forceclosed';
| |
| 89 |
$svgchart = $drawsvgchart->createChart($bugs_array, $legend, $link); | |
| 80 | 90 | |
| 81 |
foreach ($versions as $version) | |
| 82 |
{
| |
| 83 |
$version = $version['version']; | |
| 84 |
$bugs = $project_bugs->countReports($this->id, $version); | |
| 85 |
// TEST VALUES | |
| 86 |
if ($version == 'trunk') | |
| 87 |
$bugs = 42; | |
| 88 |
elseif ($version == '0.42') | |
| 89 |
$bugs = 22; | |
| 90 |
elseif ($version == '0.9') | |
| 91 |
$bugs = 16; | |
| 92 |
elseif ($version == 'francoismarcel') | |
| 93 |
$bugs = 11; | |
| 94 |
elseif ($version == '0.1rc1_uvr-X86') | |
| 95 |
$bugs = 5; | |
| 96 |
elseif ($version == '1.0') | |
| 97 |
$bugs = 33; | |
| 98 |
elseif ($version == '1.5') | |
| 99 |
$bugs = 0; | |
| 100 |
else | |
| 101 |
$bugs = 0; | |
| 102 |
| |
| 91 |
if (!$drawsvgchart->has_errors())
| |
| 92 |
{
| |
| 93 |
Header('Content-Type: image/svg+xml; charset=utf-8');
| |
| 94 |
echo $drawsvgchart->getXMLOutput(); | |
| 95 |
} | |
| 96 |
else | |
| 97 |
exit(i18n('Not enough values to proceed!'));
| |
| 98 |
} | |
| 99 |
elseif ($page[4] == 'contributors') | |
| 100 |
{
| |
| 101 |
$commits = getClass('projects.commits', $this->database);
| |
| 102 |
$datas = $commits->getProjectContributors($this->id); | |
| 103 | 103 | |
| 104 |
$bugs_total = $bugs_total + $bugs; | |
| 105 |
$bugs_array[$version] = $bugs; | |
| 106 |
} | |
| 104 |
$legend = array('#5276A9', 'commits');
| |
| 105 |
$link = $this->baseurl.'users/show/{data}';
| |
| 106 |
$svgchart = $drawsvgchart->createChart($datas, array($legend), $link); | |
| 107 | 107 | |
| 108 |
$max_value = max($bugs_array); | |
| 109 |
$x = ($max_value / 100 * 110); | |
| 110 |
$final_value = (int)($x - ($x % 4)); | |
| 108 |
if (!$drawsvgchart->has_errors())
| |
| 109 |
{
| |
| 110 |
Header('Content-Type: image/svg+xml; charset=utf-8');
| |
| 111 |
echo $drawsvgchart->getXMLOutput(); | |
| 112 |
} | |
| 113 |
else | |
| 114 |
exit(i18n('Not enough values to proceed!'));
| |
| 115 |
} | |
| 116 |
elseif ($page[4] == 'history') | |
| 117 |
{
| |
| 118 |
$commits = getClass('projects.commits', $this->database);
| |
| 119 |
$datas = $commits->getProjectHistory($this->id); | |
| 111 | 120 | |
| 112 |
$scale[4] = $final_value * 4/4; | |
| 113 |
$scale[3] = $final_value * 3/4; | |
| 114 |
$scale[2] = $final_value * 2/4; | |
| 115 |
$scale[1] = $final_value * 1/4; | |
| 121 |
$legend = array('#CD3333', 'commits');
| |
| 122 |
$link = FALSE; | |
| 123 |
$svgchart = $drawsvgchart->createChart($datas, array($legend), $link, TRUE); | |
| 116 | 124 | |
| 117 |
if ($scale[4] == 0) | |
| 118 |
exit('Error: not enough values to proceed.');
| |
| 119 | ||
| 120 |
echo '<?xml-stylesheet href="'.$this->baseurl.'inc/templates/svg-graphics.css" type="text/css"?> | |
| 121 |
<svg | |
| 122 |
xmlns:svg="http://www.w3.org/2000/svg" | |
| 123 |
xmlns="http://www.w3.org/2000/svg" | |
| 124 |
xmlns:xlink="http://www.w3.org/1999/xlink" | |
| 125 |
version="1.0" | |
| 126 |
width="450" | |
| 127 |
height="250" | |
| 128 |
id="svg"> | |
| 129 | ||
| 130 |
<g class="static-background"> | |
| 131 |
<path d="M 40, 14 L 55, 14" id="legendline" | |
| 132 |
stroke="#5276A9" stroke-width="2px"/> | |
| 133 |
<text x="57" y="17" text-anchor="start" id="reftext" | |
| 134 |
fill="#5276A9" font-size="11px" font-family="\'DejaVu sans\', Verdana, sans-serif"> | |
| 135 |
'.i18n('bugs reported').'
| |
| 136 |
</text> | |
| 137 | ||
| 138 |
<path d="M 40, 25 L 55, 25" id="legendline" | |
| 139 |
stroke="#CD3333" stroke-width="2px" /> | |
| 140 |
<text x="57" y="27" text-anchor="start" id="reftext" | |
| 141 |
fill="#CD3333" font-size="11px" font-family="\'DejaVu sans\', Verdana, sans-serif"> | |
| 142 |
'.i18n('open bugs').'
| |
| 143 |
</text> | |
| 144 | ||
| 145 |
<path d="M 38, 33 L 430, 33" stroke="#CED0D5" stroke-witdh="1px"/> | |
| 146 |
<text x="34" y="36" text-anchor="end" class="refleft">'.$scale[4].'</text> | |
| 147 |
<path d="M 38, 83 L 430, 83" stroke="#EAEAEA" stroke-witdh="1px"/> | |
| 148 |
<text x="34" y="86" text-anchor="end" class="refleft">'.$scale[3].'</text> | |
| 149 |
<path d="M 38, 133 L 430, 133" stroke="#EAEAEA" stroke-witdh="1px"/> | |
| 150 |
<text x="34" y="136" text-anchor="end" class="refleft">'.$scale[2].'</text> | |
| 151 |
<path d="M 38,183 L 430,183" stroke="#EAEAEA" stroke-witdh="1px"/> | |
| 152 |
<text x="34" y="186" text-anchor="end" class="refleft">'.$scale[1].'</text> | |
| 153 | ||
| 154 |
<text x="34" y="236" text-anchor="end" class="refleft">0</text>'; | |
| 155 | ||
| 156 |
$j = 50; | |
| 157 |
foreach ($bugs_array as $version => $bugs) | |
| 158 |
{
| |
| 159 |
$i = 18 + $j; | |
| 160 |
echo ' | |
| 161 | ||
| 162 |
<path d="M '.$i.',234 L '.$i.',238" stroke="#596171" stroke-width="2px"/> | |
| 163 |
<text x="'.$i.'" y="248" text-anchor="middle" class="reftext"> | |
| 164 |
<a xlink:href="'.$this->baseurl.'project/'.$this->dbname.'/bugs/version/'.$version.'/forceclosed" target="_blank">'.mb_substr($version, 0, 6).'</a></text>'; | |
| 165 |
$j = $j + 50; | |
| 125 |
if (!$drawsvgchart->has_errors())
| |
| 126 |
{
| |
| 127 |
Header('Content-Type: image/svg+xml; charset=utf-8');
| |
| 128 |
echo $drawsvgchart->getXMLOutput(); | |
| 129 |
} | |
| 130 |
else | |
| 131 |
exit(i18n('Not enough values to proceed!'));
| |
| 132 |
} | |
| 166 | 133 |
} |
| 167 | ||
| 168 |
echo ' | |
| 169 |
</g> | |
| 170 | ||
| 171 |
<defs> | |
| 172 |
<mask id="barmask"> | |
| 173 |
<rect x="0" y="12" width="410" height="220" fill="#FFFFFF"/> | |
| 174 |
</mask> | |
| 175 |
<rect id="focusbar" width="14" height="211" y="34" | |
| 176 |
style="fill:black;opacity:0"/> | |
| 177 |
<path id="bubble" | |
| 178 |
d="M 4.7871575,0.5 L 39.084404,0.5 C 41.459488,0.5 43.371561,2.73 43.371561,5.5 L 43.371561,25.49999 C 43.371561,27.07677 43.83887,41.00777 42.990767,40.95796 C 42.137828,40.90787 37.97451,30.49999 36.951406,30.49999 L 4.7871575,30.49999 C 2.412072,30.49999 0.5,28.26999 0.5,25.49999 L 0.5,5.5 C 0.5,2.73 2.412072,0.5 4.7871575,0.5 z" | |
| 179 |
fill="none" fill-opacity="0.9" | |
| 180 |
stroke="none" stroke-opacity="0.8" stroke-width="1px"/> | |
| 181 |
</defs> | |
| 182 | ||
| 183 |
<g mask="url(#barmask)"> | |
| 184 |
<defs> | |
| 185 |
<rect id="graphicbar" width="12" height="200" rx="2" ry="1" | |
| 186 |
fill="#6C84C0" fill-opacity="0.6" | |
| 187 |
stroke="#5276A9" stroke-width="1px"/> | |
| 188 | ||
| 189 |
<rect style="fill:#8B2323" | |
| 190 |
id="rectpoint" | |
| 191 |
width="3" | |
| 192 |
height="3" /> | |
| 193 |
</defs>'; | |
| 194 | ||
| 195 |
$x_base = 35; | |
| 196 |
$y_base = 20; | |
| 197 | ||
| 198 |
$previous_openbugs = 286; | |
| 199 |
$previous_xposition = 33; | |
| 200 | ||
| 201 |
$chart_defs = ''; | |
| 202 |
foreach ($bugs_array as $version => $bugs) | |
| 203 |
{
| |
| 204 |
$x = 27 + $x_base; | |
| 205 |
$y = 107 + $y_base; | |
| 206 | ||
| 207 |
$buga = $project_bugs->countReportsByStatus($this->id, 'unconfirmed', $version); | |
| 208 |
$bugb = $project_bugs->countReportsByStatus($this->id, 'confirmed', $version); | |
| 209 |
$bugc = $project_bugs->countReportsByStatus($this->id, 'working', $version); | |
| 210 |
$bugd = $project_bugs->countReportsByStatus($this->id, 'needinformations', $version); | |
| 211 |
$buge = $project_bugs->countReportsByStatus($this->id, 'needcontributors', $version); | |
| 212 |
$bugf = $project_bugs->countReportsByStatus($this->id, 'needtests', $version); | |
| 213 |
$bugs_open = $buga + $bugb + $bugc + $bugd + $buge + $bugf; | |
| 214 |
// TEST VALUES | |
| 215 |
if ($version == 'trunk') | |
| 216 |
$bugs_open = 31; | |
| 217 |
elseif ($version == '0.42') | |
| 218 |
$bugs_open = 20; | |
| 219 |
elseif ($version == '0.9') | |
| 220 |
$bugs_open = 1; | |
| 221 |
elseif ($version == 'francoismarcel') | |
| 222 |
$bugs_open = 5; | |
| 223 |
elseif ($version == '0.1rc1_uvr-X86') | |
| 224 |
$bugs_open = 5; | |
| 225 |
elseif ($version == '1.0') | |
| 226 |
$bugs_open = 2; | |
| 227 |
elseif ($version == '1.5') | |
| 228 |
$bugs_open = 0; | |
| 229 |
else | |
| 230 |
$bugs_open = 0; | |
| 231 |
| |
| 232 | ||
| 233 |
$openbugs = 233 - ceil($bugs_open / ($scale[4] / 100) * 2); | |
| 234 |
$top = 233 - ceil($bugs / ($scale[4] / 100) * 2); | |
| 235 | ||
| 236 |
if ($x != (27 + 35)) | |
| 237 |
$chart_defs .= 'L '.($x + 6).' '.$openbugs.' '; | |
| 238 |
else | |
| 239 |
$chart_defs .= 'M '.($previous_xposition + 6).' '.$previous_openbugs.' L '.($x + 6).' '.$openbugs.' '; | |
| 240 | ||
| 241 |
echo ' | |
| 242 | ||
| 243 |
<g class="gbar"> | |
| 244 |
<use xlink:href="#focusbar" x="'.$x.'"/> | |
| 245 |
<use xlink:href="#graphicbar" x="'.$x.'" y="'.$top.'"/> | |
| 246 |
<use xlink:href="#bubble" x="'.($x - 37).'" y="'.($top - 42).'"/> | |
| 247 |
<text class="bubbletext" fill="none" x="'.($x - 16).'" y="'.($top - 20).'">'.$bugs.'</text> | |
| 248 |
</g>'; | |
| 249 | ||
| 250 |
if ($openbugs != 286) | |
| 251 |
echo ' | |
| 252 |
<g class="rectpoint"> | |
| 253 |
<use xlink:href="#rectpoint" x="'.($x + 4).'" y="'.($openbugs - 1).'" /> | |
| 254 |
</g>'; | |
| 255 | ||
| 256 |
$x_base = $x_base + 50; | |
| 257 |
$y_base = $y_base + 20; | |
| 258 |
$previous_openbugs = $openbugs; | |
| 259 |
$previous_xposition = $x; | |
| 260 |
} | |
| 261 | ||
| 262 |
echo ' | |
| 263 | ||
| 264 |
<path d="'.$chart_defs.'" stroke="#CD3333" stroke-width="1px" fill="none" /> | |
| 265 |
</g> | |
| 266 | ||
| 267 |
<g class="static-foreground"> | |
| 268 |
<path d="M 38,233 L 430,233" stroke="#2F4F77" stroke-width="2px"/> | |
| 269 |
</g> | |
| 270 |
</svg>'; | |
| 271 | 134 |
} |
| 272 | ||
| 273 | 135 |
} |
| 274 | 136 |
?> |
| 275 | 137 |
| Old | New | Code |
|---|---|---|
| 50 | 50 |
if (!empty($value) || $value == 0) |
| 51 | 51 |
$this->page[$key] = $value; |
| 52 | 52 | |
| 53 |
// Popularity contest | |
| 54 |
// Each projects have a popularity score and this score is resetted each months. | |
| 55 |
$cfg = getClass('config', $this->ct_db);
| |
| 56 |
$timestamp = $cfg->get('projects', 'popularity-timestamp');
| |
| 57 |
if (!$timestamp || ( $timestamp + (86400 * 30) ) < time()) | |
| 58 |
{
| |
| 59 |
// Reset popularity for each projects | |
| 60 |
$this->ct_db->update('projects', array('popularity' => 0), FALSE);
| |
| 61 | ||
| 62 |
// Reset contest | |
| 63 |
$cfg->update('projects', 'popularity-timestamp', time());
| |
| 64 |
$cfg->update('projects', 'overall-popularity', 0);
| |
| 65 |
} | |
| 66 | ||
| 67 |
// Cache maximum | |
| 68 |
$this->cache_max_files = (int)$cfg->get('global', 'cache-max-files');
| |
| 69 | ||
| 53 | 70 |
// Prepare |
| 54 | 71 |
switch ($this->page[1]) |
| 55 | 72 |
{
|
| 80 | 97 |
/** |
| 81 | 98 |
* Parse API |
| 82 | 99 |
* |
| 83 |
* Print the XML outpult | |
| 100 |
* Print the XML output | |
| 84 | 101 |
*/ |
| 85 | 102 |
function parseAPI () |
| 86 | 103 |
{
|
| 90 | 107 |
elseif ($this->page[2] == 'project') |
| 91 | 108 |
$mod = $this->basedir.'/inc/modules/project/views/default.php'; |
| 92 | 109 |
elseif ($this->page[2] == 'search') |
| 93 |
exit('Not implemented.');
| |
| 110 |
$mod = $this->basedir.'/inc/modules/search/views/default.php';
| |
| 94 | 111 |
else |
| 95 | 112 |
exit('CodingTeam OpenForge API');
|
| 96 | 113 | |
| 101 | 118 |
$view_api = new View($this->ct_session, $this->ct_db, $this->page, |
| 102 | 119 |
$this->error, $this->langlist, $this->lang); |
| 103 | 120 |
$openforge_array = $view_api->showAPI(); |
| 104 | ||
| 105 |
if (!is_array($openforge_array)) | |
| 106 |
exit('CodingTeam OpenForge API');
| |
| 107 | 121 |
} |
| 108 | 122 |
else |
| 109 | 123 |
exit('CodingTeam OpenForge API');
|
| 110 | ||
| 111 |
// Create the OpenForge document | |
| 112 |
Header("Content-Type: application/xml; charset=utf-8");
| |
| 113 |
$xml = new DOMDocument('1.0', 'utf-8');
| |
| 114 |
$openforge = $xml->createElement('openforge');
| |
| 115 |
$xml->appendChild($openforge); | |
| 116 | ||
| 117 |
// Append the forge info | |
| 118 |
$forge = $openforge->appendChild($xml->createElement('forge'));
| |
| 119 |
$forge->appendChild($xml->createElement('name', 'CodingTeam'));
| |
| 120 |
$forge->appendChild($xml->createElement('url', $this->baseurl));
| |
| 121 |
$forge->appendChild($xml->createElement('version', file_get_contents($this->basedir.'/VERSION')));
| |
| 122 |
$forge->appendChild($xml->createElement('apiversion', 0.1));
| |
| 123 | ||
| 124 |
// Append the results sended by the module | |
| 125 |
$project = $xml->createElement($this->page[2]); | |
| 126 | ||
| 127 |
foreach ($openforge_array as $key => $value) | |
| 128 |
{
| |
| 129 |
// If an array is returned, we generate attribute, childs and so many :) | |
| 130 |
if (is_array($value)) | |
| 131 |
{
| |
| 132 |
$xml_tag = $project->appendChild($xml->createElement($key, $value['label'])); | |
| 133 | ||
| 134 |
if (array_key_exists('attribute', $value))
| |
| 135 |
foreach ($value['attribute'] as $attrkey => $attrvalue) | |
| 136 |
$xml_tag->setAttribute($attrkey, $attrvalue); | |
| 137 | ||
| 138 |
if (array_key_exists('parent', $value))
| |
| 139 |
foreach ($value['parent'] as $childkey => $childvalue) | |
| 140 |
$xml_tag->appendChild($xml->createElement(mb_substr($key, 0, -1), $childvalue)); | |
| 141 |
} | |
| 142 |
else | |
| 143 |
$project->appendChild($xml->createElement($key, $value)); | |
| 144 |
} | |
| 145 | ||
| 146 |
$openforge->appendChild($project); | |
| 147 | ||
| 148 |
// Show the result | |
| 149 |
$xml->formatOutput = true; | |
| 150 |
echo $xml->saveXML(); | |
| 151 | 124 |
} |
| 152 | 125 | |
| 153 | 126 | |
| 170 | 143 | |
| 171 | 144 |
// Cache Atom feed for 7 days max. |
| 172 | 145 |
$cachenamefile = $this->basedir.'/public/cache/atom/'.$this->lang.'-'.str_replace('/', '-', getURLbyTags($this->page));
|
| 146 | ||
| 173 | 147 |
if ( (file_exists($cachenamefile) && filemtime($cachenamefile) < time() - ( 3600 * 24 * 7 )) || !file_exists($cachenamefile) ) |
| 174 | 148 |
{
|
| 175 | 149 |
// Find the requested module view |
| 255 | 229 |
$xml->formatOutput = true; |
| 256 | 230 |
$tpl_show = $xml->saveXML(); |
| 257 | 231 | |
| 232 |
// Maximum files in cache
| |
| 233 |
$cachedir_ = $this->basedir.'/public/cache/atom/'; | |
| 234 |
$cachedir = opendir($cachedir_); | |
| 235 | ||
| 236 |
$counter = 0; | |
| 237 |
$cache_files = array(); | |
| 238 | ||
| 239 |
// Count files in cache and create array | |
| 240 |
while($f = readdir($cachedir)) | |
| 241 |
if (is_file($cachedir_.$f)) | |
| 242 |
{
| |
| 243 |
$cache_files[filemtime($cachedir_.$f)] = $cachedir_.$f; | |
| 244 | ||
| 245 |
$counter ++; | |
| 246 |
} | |
| 247 |
closedir($cachedir); | |
| 248 |
ksort($cache_files); | |
| 249 | ||
| 250 |
// If we need to delete the oldest file before save our new one | |
| 251 |
if ((count($cache_files) - 1) > ($this->cache_max_files / 2)) | |
| 252 |
unlink(reset($cache_files)); | |
| 253 | ||
| 258 | 254 |
// Write in the cache |
| 259 | 255 |
$filec = fopen($cachenamefile, 'w'); |
| 260 | 256 |
fwrite($filec, $tpl_show); |
| 358 | 354 |
$xml->formatOutput = true; |
| 359 | 355 |
$tpl_show = $xml->saveXML(); |
| 360 | 356 | |
| 357 |
// Maximum files in cache | |
| 358 |
$cachedir_ = $this->basedir.'/public/cache/rss/'; | |
| 359 |
$cachedir = opendir($cachedir_); | |
| 360 | ||
| 361 |
$counter = 0; | |
| 362 |
$cache_files = array(); | |
| 363 | ||
| 364 |
// Count files in cache and create array | |
| 365 |
while($f = readdir($cachedir)) | |
| 366 |
if (is_file($cachedir_.$f)) | |
| 367 |
{
| |
| 368 |
$cache_files[filemtime($cachedir_.$f)] = $cachedir_.$f; | |
| 369 | ||
| 370 |
$counter ++; | |
| 371 |
} | |
| 372 |
closedir($cachedir); | |
| 373 |
ksort($cache_files); | |
| 374 | ||
| 375 |
// If we need to delete the oldest file before save our new one | |
| 376 |
if ((count($cache_files) - 1) > ($this->cache_max_files / 2)) | |
| 377 |
unlink(reset($cache_files)); | |
| 378 | ||
| 361 | 379 |
// Write in the cache |
| 362 | 380 |
$filec = fopen($cachenamefile, 'w'); |
| 363 | 381 |
fwrite($filec, $tpl_show); |
| 389 | 407 | |
| 390 | 408 |
// If a > 0 the page cannot be stored in the cache |
| 391 | 409 |
$a = 0; |
| 392 |
$nocache_keywords = array('register', 'logout', 'deleteadmin', 'password', 'delete', 'admin', 'new', 'add', 'edit', 'answer', 'search', 'join', 'vote');
| |
| 410 |
$nocache_keywords = array('register', 'logout', 'deleteadmin', 'password', 'delete', 'admin',
| |
| 411 |
'new', 'add', 'edit', 'answer', 'search', 'join', 'vote'); | |
| 393 | 412 |
foreach ($nocache_keywords as $key) |
| 394 | 413 |
if (in_array($key, $this->page)) |
| 395 | 414 |
$a ++; |
| 431 | 450 |
else |
| 432 | 451 |
$additional = ''; |
| 433 | 452 | |
| 453 |
// Maximum files in cache | |
| 454 |
$cachedir_ = $this->basedir.'/public/cache/xhtml/'; | |
| 455 |
$cachedir = opendir($cachedir_); | |
| 456 | ||
| 457 |
$counter = 0; | |
| 458 |
$cache_files = array(); | |
| 459 | ||
| 460 |
// Count files in cache and create array | |
| 461 |
while($f = readdir($cachedir)) | |
| 462 |
if (is_file($cachedir_.$f)) | |
| 463 |
{
| |
| 464 |
$cache_files[filemtime($cachedir_.$f)] = $cachedir_.$f; | |
| 465 | ||
| 466 |
$counter ++; | |
| 467 |
} | |
| 468 |
closedir($cachedir); | |
| 469 |
ksort($cache_files); | |
| 470 | ||
| 471 |
// If we need to delete the oldest file before save our new one | |
| 472 |
if ((count($cache_files) - 1) > $this->cache_max_files) | |
| 473 |
unlink(reset($cache_files)); | |
| 474 | ||
| 434 | 475 |
// Save in cache |
| 435 | 476 |
file_put_contents($file, $additional.$view['content']); |
| 436 | 477 |
$content = $view['content']; |
| 597 | 638 |
$temp['link_tou'] = i18n('Terms of Use');
|
| 598 | 639 |
$temp['link_admin'] = i18n('Administration');
|
| 599 | 640 | |
| 600 |
// Generate the NotepadMenu | |
| 641 |
// Generate the menu
| |
| 601 | 642 |
$tabs = array(); |
| 602 | 643 |
$modlist = array(); |
| 603 | 644 |
$modulesdir = opendir($this->basedir.'/inc/modules/'); |
| 604 | 645 |
| Old | New | Code |
|---|---|---|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 |
/** |
| 43 |
* Get users list | |
| 44 |
* | |
| 45 |
* @return | |
| 46 |
* | |
| 47 |
*/ | |
| 48 |
function getUsersList($where, $limit) | |
| 49 |
{
| |
| 50 |
$req0 = $this->db->select('users', $where, 'id');
| |
| 51 |
$req1 = $this->db->select('users', $where, '*', 'ORDER BY date DESC '.$limit);
| |
| 52 | ||
| 53 |
return array(count($req0), $req1); | |
| 54 |
} | |
| 55 | ||
| 56 | ||
| 57 |
/** | |
| 43 | 58 |
* Get users number |
| 44 | 59 |
* |
| 45 | 60 |
* @return |
| 46 | 61 |
| Old | New | Code |
|---|---|---|
| 28 | 28 |
* this page: http://en.wikipedia.org/wiki/Comparison_of_free_software_licences |
| 29 | 29 |
*/ |
| 30 | 30 | |
| 31 |
$licenses['afl'] = 'Academic Free License'; | |
| 32 | 31 |
$licenses['al20'] = 'Apache License 2.0'; |
| 33 |
$licenses['asl'] = 'Apache Software License'; | |
| 34 |
$licenses['apsl'] = 'Apple Public Source License'; | |
| 35 | 32 |
$licenses['bsd'] = 'BSD License'; |
| 36 |
$licenses['cpl'] = 'Common Public License'; | |
| 37 | 33 |
$licenses['cecill'] = 'CeCILL'; |
| 38 |
$licenses['efl2'] = 'Eiffel Forum License 2.0'; | |
| 39 |
$licenses['epl'] = 'Eclipse Public License'; | |
| 34 |
$licenses['cpl'] = 'Common Public License';
| |
| 40 | 35 |
$licenses['gnuagpl'] = 'GNU Affero General Public License'; |
| 41 | 36 |
$licenses['gnugpl'] = 'GNU General Public License'; |
| 42 | 37 |
$licenses['gnulgpl'] = 'GNU Lesser General Public License'; |
| 43 |
$licenses['ibmpl'] = 'IBM Public License'; | |
| 44 |
$licenses['iosl'] = 'Intel Open Source License'; | |
| 45 |
$licenses['mpl'] = 'Mozilla Public License (1.0, 1.1)'; | |
| 46 |
$licenses['npl'] = 'Netscape Public License (1.0, 1.1)'; | |
| 47 |
$licenses['osl'] = 'Open Software License'; | |
| 48 |
$licenses['phpl'] = 'PHP License'; | |
| 49 |
$licenses['pal'] = 'Perl Artistic License'; | |
| 50 |
$licenses['cnripl'] = 'Python License'; | |
| 51 |
$licenses['psfl'] = 'Python Software Foundation License'; | |
| 52 |
$licenses['sl'] = 'Sleepycat Software Product License'; | |
| 53 |
$licenses['sissl'] = 'Sun Industry Standards Source License'; | |
| 54 |
$licenses['spl'] = 'Sun Public License'; | |
| 55 |
$licenses['w3c'] = 'W3C Software License'; | |
| 56 |
$licenses['wxwll'] = 'wxWindows Library License'; | |
| 57 |
$licenses['zll'] = 'zlib/libpng'; | |
| 58 |
$licenses['zpl'] = 'Zope Public License'; | |
| 38 |
$licenses['mit'] = 'X11/MIT License';
| |
| 59 | 39 |
?> |
| 60 | 40 |
| Old | New | Code |
|---|---|---|
| 57 | 57 |
elseif (is_string($value)) |
| 58 | 58 |
$type = 's'; |
| 59 | 59 | |
| 60 |
// Authorize errors | |
| 61 |
if (!strstr($str, '%('.$key.')d') && $type == 'd')
| |
| 62 |
$type = 's'; | |
| 63 | ||
| 60 | 64 |
// Replace |
| 61 | 65 |
$str = str_replace('%('.$key.')'.$type, $value, $str);
|
| 62 | 66 |
} |
| 63 | 67 |
| Old | New | Code |
|---|---|---|
| 61 | 61 |
'.i18n('You are not logged in.').'<br />
|
| 62 | 62 |
<a href="users/register">'.i18n('Register').'</a> -
|
| 63 | 63 |
<a href="users/password">'.i18n('Password remember').'</a><br />
|
| 64 |
<input type="text" size="15" maxlength="255" name="nickname" /> | |
| 65 |
<label><input type="checkbox" name="auto" checked="checked" />'.i18n('Automatic').'</label><br />
| |
| 66 |
<input type="password" size="15" maxlength="255" name="password" /> | |
| 64 |
<input type="text" size="15" maxlength="255" name="nickname" tabindex="1" />
| |
| 65 |
<label><input type="checkbox" name="auto" checked="checked" tabindex="3" />'.i18n('Automatic').'</label><br />
| |
| 66 |
<input type="password" size="15" maxlength="255" name="password" tabindex="2" /> | |
| 67 | 67 |
<input class="submit" type="submit" value="'.i18n('Log in').'" />
|
| 68 | 68 |
</p> |
| 69 | 69 |
</form>'; |
| 70 | 70 |
| Old | New | Code |
|---|---|---|
| 31 | 31 |
$this->in_array = array('projects' => i18n('Projects'),
|
| 32 | 32 |
'projects-bugs' => i18n('Bugs'),
|
| 33 | 33 |
'projects-doc' => i18n('Documentation'),
|
| 34 |
'projects-downloads' => i18n('Downloads'),
| |
| 35 | 34 |
'projects-forum' => i18n('Forum'),
|
| 36 | 35 |
'projects-news' => i18n('News'),
|
| 37 |
'projects-screenshots' => i18n('Screenshots'),
| |
| 38 |
'projects-todo' => i18n('Todo list'),
| |
| 39 |
'notepad' => i18n('Notepad'),
| |
| 40 | 36 |
'users' => i18n('Users')
|
| 41 | 37 |
); |
| 42 | 38 |
} |
| 43 | 39 |
| Old | New | Code |
|---|---|---|
| 36 | 36 | |
| 37 | 37 |
// Meta tags |
| 38 | 38 |
$this->metatags = array('title' => i18n('Index'),
|
| 39 |
'feed' => 'projects', | |
| 39 |
'feed' => 'projects',
| |
| 40 | 40 |
'description' => '', |
| 41 | 41 |
'keywords' => '' |
| 42 | 42 |
); |
| 72 | 72 |
<h4>'.i18n('Latest commits').'</h4>
|
| 73 | 73 |
<ul>'; |
| 74 | 74 | |
| 75 |
global $basedir; | |
| 76 |
global $baseurl; | |
| 77 |
if (is_file($basedir.'/public/svn/commits.log')) | |
| 75 |
$commits = getClass('projects.commits', $this->ct_db);
| |
| 76 |
$commits_list = $commits->getLatests(FALSE, 4); | |
| 77 |
foreach ($commits_list as $commit) | |
| 78 | 78 |
{
|
| 79 |
$file = fopen($basedir.'/public/svn/commits.log', 'r'); | |
| 79 |
$this->project->load($commit['projectid']);
| |
| 80 |
$project_name = htmlspecialchars($this->project->getName()); | |
| 81 |
$project_dbname = htmlspecialchars($this->project->getDbname()); | |
| 80 | 82 | |
| 81 |
while (!feof($file)) | |
| 82 |
{
| |
| 83 |
$line = fgets($file, 1024); | |
| 84 |
$array = explode('/', $line);
| |
| 83 |
$user_name = htmlspecialchars($commit['author']);
| |
| 85 | 84 | |
| 86 |
if (!empty($array[0]) && $this->project->load($array[0], 'dbname')) | |
| 87 |
{
| |
| 88 |
$rev = $array[1]; | |
| 89 |
$prev_rev = $array[1] - 1; | |
| 85 |
$this->maincontent .= '<li style="background: #F8F8FF;">
| |
| 86 |
<a href="project/'.$project_dbname.'/browse/diff/'.$commit['prev_rev'].'/'.$commit['new_rev'].'"> | |
| 87 |
<strong>'.map_str(htmlspecialchars($commit['log']), 35).'</strong></a><br /> | |
| 90 | 88 | |
| 91 |
$cmd = escapeshellcmd('svn log '.$baseurl.'svn/'.$array[0].' -r'.$rev.' --xml');
| |
| 92 |
ob_start(); | |
| 93 |
passthru($cmd); | |
| 94 |
$xml = ob_get_clean(); | |
| 89 |
<span style="font-style: italic;color: #8e8e8e;font-size: 0.8em;">
| |
| 90 |
'.i18n('Revision %(rev)d commited by %(author)s on %(project)s',
| |
| 91 |
array('rev' => (int)$commit['new_rev'],
| |
| 92 |
'author' => '<a href="users/show/'.$user_name.'">'.$user_name.'</a>', | |
| 93 |
'project' => '<strong>'.$project_name.'</strong>' | |
| 94 |
)).'</span></li>'; | |
| 95 | 95 | |
| 96 |
$simplexml = simplexml_load_string($xml); | |
| 97 | ||
| 98 |
$project_dbname = htmlspecialchars($this->project->getDbname()); | |
| 99 |
$project_name = htmlspecialchars($this->project->getName()); | |
| 100 | ||
| 101 |
$user_name = htmlspecialchars($simplexml->logentry->author); | |
| 102 |
$commit_log = htmlspecialchars($simplexml->logentry->msg); | |
| 103 | ||
| 104 |
$this->maincontent .= '<li style="background: #F8F8FF;"><a href="project/'.$project_dbname.'/svn/diff/'.$prev_rev.'/'.$rev.'"><strong>'.map_str($commit_log, 35).'</strong></a><br /> | |
| 105 |
<span style="font-style: italic;color: #8e8e8e;font-size: 0.8em;"> | |
| 106 |
'.i18n('Revision %(rev)d commited by %(author)s on %(project)s',
| |
| 107 |
array('rev' => (int)$rev,
| |
| 108 |
'author' => '<a href="users/show/'.$user_name.'">'.$user_name.'</a>', | |
| 109 |
'project' => '<strong>'.$project_name.'</strong>' | |
| 110 |
)).'</span></li>'; | |
| 111 | ||
| 112 |
$this->project->unload(); | |
| 113 |
} | |
| 114 |
} | |
| 115 |
fclose($file); | |
| 96 |
$this->project->unload();
| |
| 116 | 97 |
} |
| 117 | 98 | |
| 118 | 99 |
$this->maincontent .= '</ul> |
| 119 | 100 |
| Old | New | Code |
|---|---|---|
| 22 | 22 |
<view name="browse" active="TRUE"/> |
| 23 | 23 |
<view name="timeline" active="TRUE"/> |
| 24 | 24 |
<view name="todo" active="FALSE"/> |
| 25 |
<view name="translations" active="TRUE"/> | |
| 26 | 25 |
</views> |
| 27 | 26 | |
| 28 | 27 |
<behavior module-position="1" view-position="3"/> |
| 29 | 28 |
| Old | New | Code |
|---|---|---|
| 111 | 111 |
</ul> |
| 112 | 112 |
</li>'; |
| 113 | 113 | |
| 114 |
if ($this->views['translations'] == 'TRUE') | |
| 115 |
$this->pagemenu .= '<li '.( ($this->page[3] == 'translations') ? | |
| 116 |
'class="current"><a href="project/'.$this->dbname.'/translations"><img src="public/images/icons/apps/preferences-desktop-locale.png" style="float: left;padding-right: 5px;" />' : | |
| 117 |
'><a href="project/'.$this->dbname.'/translations">' ).i18n('Translation').'</a></li>';
| |
| 118 | ||
| 119 | 114 |
if ($this->views['doc'] == 'TRUE') |
| 120 | 115 |
$this->pagemenu .= '<li '.( (in_array($this->page[3], array('doc', 'screenshots', 'news'))) ?
|
| 121 | 116 |
'class="current"><a href="project/'.$this->dbname.'/doc"><img src="public/images/icons/apps/accessories-dictionary.png" style="float: left;padding-right: 5px;" />' : |
| 122 | 117 |
| Old | New | Code |
|---|---|---|
| 37 | 37 |
*/ |
| 38 | 38 |
function cmdlaunch($cmd) |
| 39 | 39 |
{
|
| 40 |
$output = array(); | |
| 41 |
$err = false; | |
| 40 |
ob_start();
| |
| 41 |
passthru(escapeshellcmd($cmd)); | |
| 42 |
$xml = ob_get_clean(); | |
| 42 | 43 | |
| 43 |
$descriptorspec = array(0 => array('pipe', 'r'),
| |
| 44 |
1 => array('pipe', 'w'),
| |
| 45 |
2 => array('pipe', 'w'));
| |
| 46 | ||
| 47 |
$resource = proc_open($cmd, $descriptorspec, $pipes); | |
| 48 |
$error = ''; | |
| 49 | ||
| 50 |
if (stream_get_contents($pipes[2]) != '') | |
| 51 |
{
| |
| 52 |
proc_close($resource); | |
| 53 |
return false; | |
| 54 |
} | |
| 55 |
if (!is_resource($resource)) | |
| 56 |
{
| |
| 57 |
proc_close($resource); | |
| 58 |
return false; | |
| 59 |
} | |
| 60 |
else | |
| 61 |
{
| |
| 62 |
$temp = stream_get_contents($pipes[1]); | |
| 63 |
proc_close($resource); | |
| 64 |
return $temp; | |
| 65 |
} | |
| 44 |
return $xml;
| |
| 66 | 45 |
} |
| 67 | 46 | |
| 68 | 47 | |
| 173 | 152 |
$part = 0; |
| 174 | 153 |
$j = 0; |
| 175 | 154 | |
| 176 |
$cmd = cmdlaunch('svn di -r '.$old.':'.$new.' '.$file);
| |
| 155 |
$cmd = cmdlaunch('svn di -r '.$old.':'.$new.' '.$file.'@'.$old);
| |
| 177 | 156 |
$file = explode("\n",$cmd);
|
| 178 | 157 | |
| 179 | 158 |
foreach($file as $line) |
| 180 | 159 |
| Old | New | Code |
|---|---|---|
| 118 | 118 |
<li class="dir"><a href="'.$UrlToSvn; |
| 119 | 119 |
if ($rev != 0) |
| 120 | 120 |
$temp .= '/r'.$rev; |
| 121 |
$temp .= '"><strong>~</strong></a></li>'; | |
| 121 |
$temp .= '"><strong>/</strong></a></li>'; | |
| 122 | 122 | |
| 123 | 123 |
for($i=1;$i<$nb;$i++) |
| 124 | 124 |
{
|
| 137 | 137 |
<thead> |
| 138 | 138 |
<tr> |
| 139 | 139 |
<th colspan="2"><span style="float: right;"><a href="'.$UrlToSvn.'/log'.$path.'">'.i18n('Revision log').'</a></span>
|
| 140 |
'._('Information on the revision').'</th>
| |
| 140 |
'.i18n('Information on the revision').'</th>
| |
| 141 | 141 |
</tr> |
| 142 | 142 |
</thead> |
| 143 | 143 |
<tbody> |
| 144 | 144 |
<tr style="background-color : #EBf0f0"> |
| 145 |
<td style="width: 20%;">'._('Revision:').'</td>
| |
| 145 |
<td style="width: 20%;">'.i18n('Revision:').'</td>
| |
| 146 | 146 |
<td>'.( ($rev == 0 && $rev != 'HEAD') ? 0 : $log['revision'].' <a href="'.$UrlToSvn.'/diff/'.($log['revision'] - 1).'/'.$info['revision'].$path.'">'.i18n('(differences)').'</a>').'</td>
|
| 147 | 147 |
</tr> |
| 148 | 148 |
<tr> |
| 149 |
<td style="width: 20%;">'._('Author:').'</td>
| |
| 149 |
<td style="width: 20%;">'.i18n('Author:').'</td>
| |
| 150 | 150 |
<td>'.( ($rev == 0 && $rev != 'HEAD') ? '-' : '<a href="users/show/'.htmlspecialchars($log['author']).'">'.htmlspecialchars($log['author']).'</a>' ).'</td> |
| 151 | 151 |
</tr> |
| 152 | 152 |
<tr style="background-color : #EBf0f0"> |
| 153 |
<td style="width: 20%;">'._('Log message:').'</td>
| |
| 153 |
<td style="width: 20%;">'.i18n('Log message:').'</td>
| |
| 154 | 154 |
<td>'.( ($rev == 0 && $rev != 'HEAD') ? '-' : nl2br(htmlspecialchars($log['msg'])) ).'</td> |
| 155 | 155 |
</tr> |
| 156 | 156 |
<tr> |
| 162 | 162 |
foreach ($revisions as $name => $rev) |
| 163 | 163 |
{
|
| 164 | 164 |
if ($i == 1) |
| 165 |
$return .= _(' to ');
| |
| 165 |
$return .= i18n(' to ');
| |
| 166 | 166 |
$return .= ' <input type="text" style="width: 5.0em;" name="'.$name.'" value="'.$rev.'"'; |
| 167 | 167 |
$return .= ' /> '; |
| 168 | 168 |
$i++; |
| 195 | 195 |
foreach ($revisions as $name => $rev) |
| 196 | 196 |
{
|
| 197 | 197 |
if ($i == 1) |
| 198 |
$return .= _(' to ');
| |
| 198 |
$return .= i18n(' to ');
| |
| 199 | 199 |
$return .= ' <input type="text" style="width: 5.0em;" name="'.$name.'" value="'.$rev.'"'; |
| 200 | 200 |
$return .= ' /> '; |
| 201 | 201 |
$i++; |
| 319 | 319 |
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS, 2); |
| 320 | 320 | |
| 321 | 321 |
if ($file===false) |
| 322 |
$return .= '<strong>'._('Revision not found.').'</strong>';
| |
| 322 |
$return .= '<strong>'.i18n('Revision not found.').'</strong>';
| |
| 323 | 323 |
else |
| 324 | 324 |
{
|
| 325 | 325 |
if ($bin) |
| 374 | 374 | |
| 375 | 375 |
$i = 1; |
| 376 | 376 | |
| 377 |
$return .= '<li class="dir"><a href="'.$url.'"><strong>~</strong></a></li>'; | |
| 377 |
$return .= '<li class="dir"><a href="'.$url.'"><strong>/</strong></a></li>'; | |
| 378 | 378 |
foreach ($tree as $level) |
| 379 | 379 |
{
|
| 380 | 380 |
$link .= '/'.$tree[$i]; |
| 386 | 386 | |
| 387 | 387 |
$return .= '</ul></div>'; |
| 388 | 388 | |
| 389 |
foreach ($file['Part'] as $part) | |
| 390 |
{
| |
| 391 |
$return .= '<table style="width: 100%;overflow: auto;display: block;"> | |
| 392 |
<thead> | |
| 393 |
<tr> | |
| 394 |
<th style="width: 3%;">'._('Old').'</th>
| |
| 395 |
<th style="width: 3%;">'._('New').'</th>
| |
| 396 |
<th>'._('Code').'</th>
| |
| 397 |
</tr> | |
| 398 |
</thead>'; | |
| 389 |
if (count($file['Part']) > 0)
| |
| 390 |
foreach ($file['Part'] as $part) | |
| 391 |
{
| |
| 392 |
$return .= '<table style="width: 100%;overflow: auto;display: block;"> | |
| 393 |
<thead> | |
| 394 |
<tr> | |
| 395 |
<th style="width: 3%;">'.i18n('Old').'</th>
| |
| 396 |
<th style="width: 3%;">'.i18n('New').'</th>
| |
| 397 |
<th>'.i18n('Code').'</th>
| |
| 398 |
</tr> | |
| 399 |
</thead>'; | |
| 399 | 400 | |
| 400 |
$LNum_old = $part['Start-']; | |
| 401 |
$LNum_new = $part['Start+']; | |
| 402 |
foreach($part['code'] as $line) | |
| 403 |
{
| |
| 404 |
switch (mb_substr($line, 0, 1)) | |
| 401 |
$LNum_old = $part['Start-'];
| |
| 402 |
$LNum_new = $part['Start+']; | |
| 403 |
foreach($part['code'] as $line) | |
| 405 | 404 |
{
|
| 406 |
case '-': | |
| 407 |
$line_ = htmlspecialchars($line); | |
| 408 |
$line = mb_substr($line_, 1, strlen($line_)); | |
| 409 |
$return .= '<tr> | |
| 410 |
<td>'.$LNum_old.'</td> | |
| 411 |
<td> </td> | |
| 412 |
<td style="background-color: #FFBBBB;"> | |
| 413 |
<pre>'.$line.'</pre> | |
| 414 |
</td>'; | |
| 415 |
$LNum_old++; | |
| 416 |
$return .= '</tr>'; | |
| 405 |
switch (mb_substr($line, 0, 1))
| |
| 406 |
{
| |
| 407 |
case '-': | |
| 408 |
$line_ = htmlspecialchars($line); | |
| 409 |
$line = mb_substr($line_, 1, strlen($line_)); | |
| 410 |
$return .= '<tr> | |
| 411 |
<td>'.$LNum_old.'</td> | |
| 412 |
<td> </td> | |
| 413 |
<td style="background-color: #FFBBBB;"> | |
| 414 |
<pre>'.$line.'</pre> | |
| 415 |
</td>'; | |
| 416 |
$LNum_old++; | |
| 417 |
$return .= '</tr>'; | |
| 417 | 418 | |
| 418 |
$latest_del = $line; | |
| 419 |
break; | |
| 419 |
$latest_del = $line;
| |
| 420 |
break; | |
| 420 | 421 | |
| 421 |
case '+': | |
| 422 |
$line_ = htmlspecialchars($line); | |
| 423 |
$line = mb_substr($line_, 1, strlen($line_)); | |
| 422 |
case '+':
| |
| 423 |
$line_ = htmlspecialchars($line); | |
| 424 |
$line = mb_substr($line_, 1, strlen($line_)); | |
| 424 | 425 | |
| 425 |
if (!empty($latest_del) && !empty($line)) | |
| 426 |
{
| |
| 427 |
for ($i=0; $i<strlen($latest_del); $i++) | |
| 428 |
if ($latest_del[$i] != $line[$i]) | |
| 426 |
if (!empty($latest_del) && !empty($line))
| |
| 427 |
{
| |
| 428 |
for ($i=0; $i<strlen($latest_del); $i++) | |
| 429 |
if ($latest_del[$i] != $line[$i]) | |
| 430 |
{
| |
| 431 |
$start = $i; | |
| 432 |
break; | |
| 433 |
} | |
| 434 | ||
| 435 |
$p_len = mb_strlen($latest_del) - 1; | |
| 436 |
$n_len = mb_strlen($line) - 1; | |
| 437 |
$i = max($p_len, $n_len); | |
| 438 |
while ($i >= 0) | |
| 429 | 439 |
{
|
| 430 |
$start = $i; | |
| 431 |
break; | |
| 432 |
} | |
| 440 |
if ($latest_del[$p_len] != $line[$n_len])
| |
| 441 |
{
| |
| 442 |
$end = $i + 1; | |
| 443 |
break; | |
| 444 |
} | |
| 433 | 445 | |
| 434 |
$p_len = mb_strlen($latest_del) - 1; | |
| 435 |
$n_len = mb_strlen($line) - 1; | |
| 436 |
$i = max($p_len, $n_len); | |
| 437 |
while ($i >= 0) | |
| 438 |
{
| |
| 439 |
if ($latest_del[$p_len] != $line[$n_len]) | |
| 440 |
{
| |
| 441 |
$end = $i + 1; | |
| 442 |
break; | |
| 446 |
$p_len --;
| |
| 447 |
$n_len --; | |
| 448 |
$i --; | |
| 443 | 449 |
} |
| 444 | 450 | |
| 445 |
$p_len --; | |
| 446 |
$n_len --; | |
| 447 |
$i --; | |
| 451 |
$new = mb_substr($line, $start, $end - $start);
| |
| 452 |
$line = str_replace($new, '<span class="diffnew">'.$new.'</span>', $line); | |
| 453 |
$latest_del = ''; | |
| 448 | 454 |
} |
| 455 |
$return .= '<tr> | |
| 456 |
<td> </td> | |
| 457 |
<td>'.$LNum_new.'</td> | |
| 458 |
<td style="background-color: #BBFFBB;"> | |
| 459 |
<pre>'.$line.'</pre> | |
| 460 |
</td>'; | |
| 461 |
$LNum_new++; | |
| 462 |
$return .= '</tr>'; | |
| 463 |
break; | |
| 449 | 464 | |
| 450 |
$new = mb_substr($line, $start, $end - $start); | |
| 451 |
$line = str_replace($new, '<span class="diffnew">'.$new.'</span>', $line); | |
| 452 |
$latest_del = ''; | |
| 453 |
} | |
| 454 |
$return .= '<tr> | |
| 455 |
<td> </td> | |
| 456 |
<td>'.$LNum_new.'</td> | |
| 457 |
<td style="background-color: #BBFFBB;"> | |
| 458 |
<pre>'.$line.'</pre> | |
| 459 |
</td>'; | |
| 460 |
$LNum_new++; | |
| 461 |
$return .= '</tr>'; | |
| 462 |
break; | |
| 465 |
case '\\':
| |
| 466 |
break; | |
| 463 | 467 | |
| 464 |
case '\\': | |
| 465 |
break; | |
| 466 | ||
| 467 |
default: | |
| 468 |
$line = htmlspecialchars($line); | |
| 469 |
$return .= '<tr> | |
| 470 |
<td>'.$LNum_old.'</td> | |
| 471 |
<td>'.$LNum_new.'</td> | |
| 472 |
<td> | |
| 473 |
<pre>'.mb_substr($line, 1, strlen($line)).'</pre> | |
| 474 |
</td>'; | |
| 475 |
$LNum_old++; | |
| 476 |
$LNum_new++; | |
| 477 |
$return .= '</tr>'; | |
| 478 |
break; | |
| 468 |
default:
| |
| 469 |
$line = htmlspecialchars($line); | |
| 470 |
$return .= '<tr> | |
| 471 |
<td>'.$LNum_old.'</td> | |
| 472 |
<td>'.$LNum_new.'</td> | |
| 473 |
<td> | |
| 474 |
<pre>'.mb_substr($line, 1, strlen($line)).'</pre> | |
| 475 |
</td>'; | |
| 476 |
$LNum_old++; | |
| 477 |
$LNum_new++; | |
| 478 |
$return .= '</tr>'; | |
| 479 |
break; | |
| 480 |
} | |
| 479 | 481 |
} |
| 482 |
$return .= '</table>'; | |
| 480 | 483 |
} |
| 481 |
$return .= '</table>'; | |
| 482 |
} | |
| 483 | 484 |
} |
| 485 | ||
| 484 | 486 |
return $return; |
| 485 | 487 |
} |
| 486 | 488 | |
| 500 | 502 |
if (!$list) |
| 501 | 503 |
$return .= '<strong>'.i18n('This file or directory does not exist.').'</strong>';
|
| 502 | 504 |
else {
|
| 503 |
$return .= '<table style="width: 100%;"> | |
| 505 |
$return .= '
| |
| 506 |
<div class="feed" style="background-image: url(\'public/images/feed.png\');"> | |
| 507 |
'.i18n('Feed subscription: %(rss)s or %(atom)s.',
| |
| 508 |
array('rss' => '<a href="rss'.htmlspecialchars($parents->UrlToSvn).'">'.i18n('RSS').'</a>',
| |
| 509 |
'atom' => '<a href="atom'.htmlspecialchars($parents->UrlToSvn).'">'.i18n('Atom').'</a>'
| |
| 510 |
)).'</div> | |
| 511 | ||
| 512 |
<table style="width: 100%;"> | |
| 504 | 513 |
<thead> |
| 505 | 514 |
<tr> |
| 506 |
<th style="width: 7%;">'._('Revision').'</th>
| |
| 507 |
<th style="width: 10%;">'._('Author').'</th>
| |
| 508 |
<th style="width: 15%;">'._('Date').'</th>
| |
| 509 |
<th>'._('Message').'</th>
| |
| 515 |
<th style="width: 7%;">'.i18n('Revision').'</th>
| |
| 516 |
<th style="width: 10%;">'.i18n('Author').'</th>
| |
| 517 |
<th style="width: 15%;">'.i18n('Date').'</th>
| |
| 518 |
<th>'.i18n('Message').'</th>
| |
| 510 | 519 |
</tr> |
| 511 | 520 |
</thead> |
| 512 | 521 |
<tbody>'; |
| 513 | 522 |
| Old | New | Code |
|---|---|---|
| 26 | 26 |
$this->ct_db = $db; |
| 27 | 27 |
} |
| 28 | 28 | |
| 29 |
function getTimeline($projectid, $_feed_=FALSE) | |
| 29 |
function getTimeline($projectid)
| |
| 30 | 30 |
{
|
| 31 | 31 |
$project = getClass('projects.projects', $this->ct_db);
|
| 32 | 32 |
$projects = $project->load($projectid); |
| 43 | 43 |
$feeds = array('atom/project/'.$dbname.'/download' => 'download',
|
| 44 | 44 |
'atom/project/'.$dbname.'/bugs' => 'bugs', |
| 45 | 45 |
'atom/project/'.$dbname.'/news' => 'news', |
| 46 |
'atom/project/'.$dbname.'/doc' => 'doc' | |
| 46 |
'atom/project/'.$dbname.'/doc' => 'doc',
| |
| 47 |
'atom/project/'.$dbname.'/browse' => 'browse' | |
| 47 | 48 |
); |
| 48 | 49 | |
| 49 | 50 |
// Fetch all feeds |
| 76 | 77 |
'text' => map_str($text, 50), |
| 77 | 78 |
'type' => $type |
| 78 | 79 |
)); |
| 79 | ||
| 80 | 80 |
} |
| 81 | 81 |
} |
| 82 | 82 |
} |
| 165 | 165 |
} |
| 166 | 166 | |
| 167 | 167 |
// Sort by date |
| 168 |
global $is_feed; | |
| 169 |
$is_feed = $_feed_; | |
| 170 | ||
| 171 | 168 |
function sort_timeline_by_date($a, $b) |
| 172 | 169 |
{
|
| 173 |
global $is_feed; | |
| 174 | ||
| 175 | 170 |
if ($a[0] == $b[0]) |
| 176 | 171 |
return 0; |
| 177 | 172 | |
| 178 |
if ($is_feed) | |
| 179 |
return ($a[0] < $b[0]) ? -1 : 1; | |
| 180 |
else | |
| 181 |
return ($a[0] < $b[0]) ? 1 : -1; | |
| 173 |
return ($a[0] < $b[0]) ? 1 : -1;
| |
| 182 | 174 |
} |
| 183 | 175 | |
| 184 | 176 |
usort($timeline, 'sort_timeline_by_date'); |
| 185 | 177 |
| Old | New | Code |
|---|---|---|
| 40 | 40 |
if (!$projects) |
| 41 | 41 |
$this->error->displayError('Project not found.', 0);
|
| 42 | 42 | |
| 43 |
$this->id = $this->project->getId(); | |
| 43 | 44 |
$this->name = htmlspecialchars($this->project->getName()); |
| 44 | 45 |
$this->dbname = htmlspecialchars($this->project->getDbname()); |
| 45 | 46 |
$this->logo = htmlspecialchars($this->project->getLogo()); |
| 57 | 58 |
$this->config->update('projects', 'overall-popularity', $new_overall);
|
| 58 | 59 | |
| 59 | 60 |
// Meta tags |
| 60 |
$this->metatags = array('title' => '',
| |
| 61 |
'feed' => '', | |
| 62 |
'description' => '', | |
| 63 |
'keywords' => '' | |
| 64 |
); | |
| 61 |
$this->metatags = array();
| |
| 65 | 62 | |
| 66 | 63 |
foreach($this->page as $folder) |
| 67 | 64 |
if (mb_strlen($folder) != 0) |
| 76 | 73 | |
| 77 | 74 |
function showFeed() |
| 78 | 75 |
{
|
| 76 |
global $baseurl; | |
| 77 |
$feed_array['title'] = i18n('%(name)s commits', array('name' => $this->name));
| |
| 78 |
$feed_array['link'] = $baseurl.'project/'.$this->dbname.'/browse/log'; | |
| 79 |
$feed_array['description'] = i18n('Latest commits for %(name)s.', array('name' => $this->name));
| |
| 80 | ||
| 81 |
$commits = getClass('projects.commits', $this->ct_db);
| |
| 82 |
$list = $commits->getLatests($this->id); | |
| 83 | ||
| 84 |
if (!empty($list)) | |
| 85 |
{
| |
| 86 |
for ($i=0; $i<count($list); $i++) | |
| 87 |
{
| |
| 88 |
$feed_array['threads'][$i]['title'] = 'r'.$list[$i]['new_rev']; | |
| 89 |
$feed_array['threads'][$i]['pubDate'] = $list[$i]['datetime']; | |
| 90 |
$feed_array['threads'][$i]['guid'] = $baseurl.'project/'.$this->dbname.'/browse/diff/'.$list[$i]['prev_rev'].'/'.$list[$i]['new_rev']; | |
| 91 |
$feed_array['threads'][$i]['link'] = $baseurl.'project/'.$this->dbname.'/browse/diff/'.$list[$i]['prev_rev'].'/'.$list[$i]['new_rev']; | |
| 92 |
$feed_array['threads'][$i]['dc:creator'] = htmlspecialchars($list[$i]['author']); | |
| 93 |
$feed_array['threads'][$i]['description'] = htmlspecialchars($list[$i]['log']); | |
| 94 |
} | |
| 95 |
} | |
| 96 | ||
| 97 |
return $feed_array; | |
| 79 | 98 |
} |
| 80 | 99 | |
| 81 | 100 |
function treatForms() |
| 164 | 183 | |
| 165 | 184 |
case 'log': |
| 166 | 185 |
$this->metatags['title'] = i18n('Log - Browse the code - %(name)s', array('name' => $this->name));
|
| 186 |
$this->metatags['feed'] = 'project/'.$this->dbname.'/browse'; | |
| 167 | 187 |
$base ++; |
| 168 | 188 |
$this->maincontent .= $this->view->log($base, $this, $ar_rep[$this->dbname]); |
| 169 | 189 |
break; |
| 170 | 190 |
| Old | New | Code |
|---|---|---|
| 1243 | 1243 |
} |

CodingTeam