Offline Server  1.6
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
admin.php
Go to the documentation of this file.
1 <?php
2 
3 function admin(&$action) {
4  $action->parent->AddJsRef("OFFLINE/Layout/admin.js");
5  $action->parent->AddCssRef("CORE:welcome.css", true);
6  $action->parent->AddCssRef("OFFLINE:admin.css");
7 
8  $command = getHttpVars('command', '');
9 
10  switch($command) {
11  case 'build':
12  return _admin_build($action);
13  break;
14  }
15 
16  $action->lay->set('STATUS_CLASS', 'nop');
17  $action->lay->set('STATUS_MESSAGE', '');
18  $action->lay->set('ERROR_LOG', '');
19 
20  return;
21 }
22 
23 function _admin_build(&$action) {
24  include_once('OFFLINE/Class.OfflineClientBuilder.php');
25 
26  $core_urlindex = $action->getParam('CORE_URLINDEX', '');
27  if( $core_urlindex == '' ) {
28  $action->ExitError(sprintf(_("OFFLINE:Parameter %s must be set"), 'CORE_URLINDEX'));
29  return;
30  }
31 
32  $dest_dir = $action->parent->getParam('OFFLINE_CLIENT_BUILD_OUTPUT_DIR', '');
33  if( ! is_dir($dest_dir) ) {
34  $action->ExitError(sprintf(_("OFFLINE:%s directory not found"), $dest_dir));
35  return;
36  }
37  if( ! is_writable($dest_dir) ) {
38  $action->ExitError(sprintf(_("OFFLINE:%s directory not writable"), $dest_dir));
39  return;
40  }
41  $dest_dir = realpath($dest_dir);
42 
43  $opts = array();
44 
45  $customize_dir = $action->parent->getParam('OFFLINE_CLIENT_CUSTOMIZE_DIR', '');
46  if( $customize_dir != '' ) {
47  if( ! is_dir($customize_dir) ) {
48  $action->ExitError(sprintf(_("OFFLINE:%s directory not found"), $customize_dir));
49  return;
50  }
51  $customize_dir = realpath($customize_dir);
52  }
53  $opts['CUSTOMIZE_DIR'] = $customize_dir;
54 
55  $ocb = new OfflineClientBuilder($dest_dir, $opts);
56 
57  $ret = $ocb->buildAll();
58  if( $ret === false ) {
59  $action->lay->set('STATUS_CLASS', 'error');
60  $action->lay->set('STATUS_MESSAGE', 'Error');
61  $action->lay->set('ERROR_LOG', htmlspecialchars($ocb->error));
62  return;
63  }
64 
65  $action->lay->set('STATUS_CLASS', 'success');
66  $action->lay->set('STATUS_MESSAGE', 'OK');
67  $action->lay->set('ERROR_LOG', '');
68  return;
69 }
70 
71 ?>
_admin_build(&$action)
Definition: admin.php:23
admin(&$action)
Definition: admin.php:3
← centre documentaire © anakeen - published under CC License - Dynacase