changed git call from https to git readonly
[atutor.git] / mods / phpdoc2 / api_install.php
1 <?php
2 define('AT_INCLUDE_PATH', '../../include/');
3 require (AT_INCLUDE_PATH.'vitals.inc.php');
4 admin_authenticate(AT_ADMIN_PRIV_PHPDOC);
5 $_custom_css = $_base_path . 'mods/phpdoc2/module.css'; // use a custom stylesheet
6
7 if (!function_exists('version_compare'))
8 {
9     print "phpDocumentor requires PHP version 4.1.0 or greater to function";
10     exit;
11 }
12
13 // Find out if we are submitting and if we are, send it
14 // This code originally by Joshua Eichorn on phpdoc.php
15 //
16 if (isset($_GET['dataform']) && empty($_REQUEST['altuserdir'])) {
17         foreach ($_GET as $k=>$v) {
18                 if (strpos( $k, 'setting_' ) === 0) {
19                         $_GET['setting'][substr( $k, 8 )] = $v;
20                 }
21         }
22
23         //ATutor presets
24         $_GET['setting']['output']                              = 'HTML:frames:DOM/earthli';            //Theme
25         $_GET['setting']['directory']                   = AT_INCLUDE_PATH;                                      //Source codes location, use "include/"
26         $_GET['setting']['defaultpackagename']  = 'ATutor '.VERSION;                            //ATutor package
27
28         //Check if the directory is writable, if not, halt.
29         if (!(is_dir($_GET['setting']['target']) && is_writable($_GET['setting']['target']))) {
30                 $msg->addError(array('API_NOT_WRITABLE', $_GET['setting']['target'], "directory", "apidoc"));
31                 header("Location: api_install.php");
32                 exit;
33         } elseif(!(is_file($_GET['setting']['target'].'/index.html') && is_writable($_GET['setting']['target'].'/index.html'))) {
34                 //Check if the index.html file is writable
35                 $msg->addError(array('API_NOT_WRITABLE', $_GET['setting']['target'].'/index.html', "file", "index.html"));
36                 header("Location: api_install.php");
37                 exit;
38         } else {
39                 //Output api convertion steps
40                 require (AT_INCLUDE_PATH.'header.inc.php');             
41                 echo "<strong>Parsing Files ...</strong><br/>";
42                 flush();
43                 echo "<div id='api_process_box'><pre>\n";
44                 /** phpdoc.inc */
45                 include("PhpDocumentor/phpDocumentor/phpdoc.inc");
46                 echo "</pre></div>\n";
47                 echo "<strong>Operation Completed!!</strong> <a href=\"mods/phpdoc2/".$_GET['setting']['target']."\" target=\"atutor_api\">View API Here</a>.";
48                 require (AT_INCLUDE_PATH.'footer.inc.php');
49                 exit;
50         }
51 }
52
53
54 // set up include path so we can find all files, no matter what
55 $GLOBALS['_phpDocumentor_install_dir'] = dirname(dirname(realpath(__FILE__)));
56 $root_dir = '';
57
58 /**
59 * common file information
60 */
61 include_once("PhpDocumentor/phpDocumentor/common.inc.php");
62 // add my directory to the include path, and make it first, should fix any errors
63 if (substr(PHP_OS, 0, 3) == 'WIN')
64 {
65         ini_set('include_path',$GLOBALS['_phpDocumentor_install_dir'].';'.ini_get('include_path'));
66 } else {
67         ini_set('include_path',$GLOBALS['_phpDocumentor_install_dir'].':'.ini_get('include_path'));
68 }
69 // find the .ini directory by parsing phpDocumentor.ini and extracting _phpDocumentor_options[userdir]
70 $ini = phpDocumentor_parse_ini_file($_phpDocumentor_install_dir . PATH_DELIMITER . 'phpDocumentor.ini', true);
71 if (isset($ini['_phpDocumentor_options']['userdir']))
72 {
73         $configdir = $ini['_phpDocumentor_options']['userdir'];
74 } else {
75         $configdir = $_phpDocumentor_install_dir . '/user';
76 }
77
78
79 /* Template starts here */
80 require (AT_INCLUDE_PATH.'header.inc.php'); ?>
81 <div id="phpdoc2_installer">
82 <form name="dataForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
83         <table>
84         <tr><td class="title"><label for="setting_title">API Title: </label></td>
85                 <td><input type="text" name="setting_title" id="setting_title" value="<?php echo 'ATutor '.VERSION; ?>" size="40" /></td></tr>
86         <tr><td class="title"><label for="setting_target">Save to... (relative path is allowed): </label></td>
87                 <td><input type="text" name="setting_target" id="setting_target" value="apidoc" size="40" /></td></tr>
88         <tr><td class="title"><label for="setting_ignore">These files will be ignored: </label></td>
89                 <td><input type="text" name="setting_ignore" id="setting_ignore" value="*.svn" size="40" /></td></tr>
90         <tr>
91                 <td><input class="buttons" type="SUBMIT" value="Go" name="submitButton" /></td>
92         </tr>
93         </table>
94         <input type="hidden" name="dataform" value="true">
95 </form>
96         <div class="license">
97                 <p>This feature is provided by <a href="http://www.phpdoc.org/" target="phpdoc">phpDocumentor 1.4.1</a>.</p>
98         </div>
99 </div>
100
101 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>