]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/cvs.php
first skeleton version of the cvs
[SourceForge/phpwiki.git] / lib / WikiDB / backend / cvs.php
1 <?php
2 rcs_id('$Id: cvs.php,v 1.1 2001-09-28 14:28:22 riessen Exp $');
3 /**
4  * Backend for handling CVS repository. 
5  *
6  * This code assumes that cvs and grep are in the path of the program
7  * which uses this code.
8  *
9  * Author: Gerrit Riessen, gerrit.riessen@open-source-consultants.de
10  */
11 require_once('lib/WikiDB/backend.php');
12
13 class WikiDB_backend_cvs
14 extends WikiDB_backend
15 {
16     function get_pagedata($pagename) {
17         
18     }
19     function update_pagedata($pagename, $newdata) {
20     }
21     function get_latest_version($pagename) {
22     }
23     function get_previous_version($pagename, $version) {
24     }
25     function get_versiondata($pagename, $version, $want_content = false) {
26     }
27     function delete_page($pagename) {
28     }
29     function delete_versiondata($pagename, $version) {
30     }
31     function set_versiondata($pagename, $version, $data) {
32     }
33     function update_versiondata($pagename, $version, $newdata) {
34     }
35     function set_links($pagename, $links) {
36     }
37     function get_links($pagename, $reversed) {
38     }
39     function get_all_revisions($pagename) {
40     }
41     function get_all_pages($include_defaulted) {
42     }
43     function text_search($search = '', $fullsearch = false) {
44     }
45     function most_popular($limit) {
46     }
47     function most_recent($params) {
48     }
49     function lock($write_lock = true) {
50     }
51     function unlock($force = false) {
52     }
53     function close () {
54     }
55     function sync() {
56     }
57     function optimize() {
58     }
59     function check() {
60     }
61     function rebuild() {
62     }
63
64     // 
65     // The rest are all internal methods, not to be used 
66     // directly.
67     //
68     /**
69      * Return a list of currently existing Wiki pages.
70      */
71     function _GetAllWikiPageNames($dirName) {
72         $namelist = array();
73         $d = opendir( $dirName );
74         $curr = 0;
75         while ( $entry = readdir( $d ) ) {
76             $namelist[$curr++] = $entry;
77         }
78
79         // TODO: do we need to do something similar to a closedir ???
80         return $namelist;
81     }
82
83     /**
84      * Recursively create all directories.
85      */
86     function _mkdir( $path, $mode ) {
87         $directoryName = dirname( $path );
88         if ( $directoryName != "." && $directoryName != "/" 
89         && $directoryName != "\\"  && !is_dir( $direcoryName ) ) {
90             $rVal = _mkdir( $directoryName, $mode );
91         }
92         else {
93             return true;
94         }
95       
96         return ($rVal && mkdir( $path, $mode ) );
97     }
98
99     /**
100      * Recursively create all directories and then the file.
101      */
102     function _createFile( $path, $mode ) {
103         _mkdir( dirname( $path ), $mode );
104         touch( $path );
105         chmod( $path, $mode );
106     }
107     
108     /**
109      * Debug function specifically for the CVS database functions.
110      * Can be deactived by setting the WikiDB['debug_file'] to ""
111      */
112     function _cvsDebug( $msg )  {
113         global $WikiDB;
114         $filename = $WikiDB['debug_file'];
115         if ( $filename == "" ) {
116             return;
117         }
118         
119         if ( !file_exists( $filename ) ) {
120             _createFile( $filename, 0755 );
121         }
122
123         if ( $fdlock = @fopen( $filename, 'a' ) ) {
124             $locked = flock( $fdlock, 2 );
125             if ( !$locked ) {
126                 fclose( $fdlock );
127                 return;
128             }
129             
130             $fdappend = @fopen( $filename, 'a' );
131             fwrite( $fdappend, ($msg . "\n") );
132             fclose( $fdappend );
133             fclose( $fdlock );
134         }
135         else {
136             print( "unable to locate/open [$filename]\n" );
137         }
138     }
139 }
140 ?>