2 rcs_id('$Id: cvs.php,v 1.1 2001-09-28 14:28:22 riessen Exp $');
4 * Backend for handling CVS repository.
6 * This code assumes that cvs and grep are in the path of the program
7 * which uses this code.
9 * Author: Gerrit Riessen, gerrit.riessen@open-source-consultants.de
11 require_once('lib/WikiDB/backend.php');
13 class WikiDB_backend_cvs
14 extends WikiDB_backend
16 function get_pagedata($pagename) {
19 function update_pagedata($pagename, $newdata) {
21 function get_latest_version($pagename) {
23 function get_previous_version($pagename, $version) {
25 function get_versiondata($pagename, $version, $want_content = false) {
27 function delete_page($pagename) {
29 function delete_versiondata($pagename, $version) {
31 function set_versiondata($pagename, $version, $data) {
33 function update_versiondata($pagename, $version, $newdata) {
35 function set_links($pagename, $links) {
37 function get_links($pagename, $reversed) {
39 function get_all_revisions($pagename) {
41 function get_all_pages($include_defaulted) {
43 function text_search($search = '', $fullsearch = false) {
45 function most_popular($limit) {
47 function most_recent($params) {
49 function lock($write_lock = true) {
51 function unlock($force = false) {
65 // The rest are all internal methods, not to be used
69 * Return a list of currently existing Wiki pages.
71 function _GetAllWikiPageNames($dirName) {
73 $d = opendir( $dirName );
75 while ( $entry = readdir( $d ) ) {
76 $namelist[$curr++] = $entry;
79 // TODO: do we need to do something similar to a closedir ???
84 * Recursively create all directories.
86 function _mkdir( $path, $mode ) {
87 $directoryName = dirname( $path );
88 if ( $directoryName != "." && $directoryName != "/"
89 && $directoryName != "\\" && !is_dir( $direcoryName ) ) {
90 $rVal = _mkdir( $directoryName, $mode );
96 return ($rVal && mkdir( $path, $mode ) );
100 * Recursively create all directories and then the file.
102 function _createFile( $path, $mode ) {
103 _mkdir( dirname( $path ), $mode );
105 chmod( $path, $mode );
109 * Debug function specifically for the CVS database functions.
110 * Can be deactived by setting the WikiDB['debug_file'] to ""
112 function _cvsDebug( $msg ) {
114 $filename = $WikiDB['debug_file'];
115 if ( $filename == "" ) {
119 if ( !file_exists( $filename ) ) {
120 _createFile( $filename, 0755 );
123 if ( $fdlock = @fopen( $filename, 'a' ) ) {
124 $locked = flock( $fdlock, 2 );
130 $fdappend = @fopen( $filename, 'a' );
131 fwrite( $fdappend, ($msg . "\n") );
136 print( "unable to locate/open [$filename]\n" );