Open Monograph Press  3.3.0
fbvVisualResults.php
1 <?php
2 
18 define('INDEX_FILE_LOCATION', dirname(dirname(__FILE__)) . '/index.php');
19 chdir(dirname(INDEX_FILE_LOCATION)); /* Change to base directory */
20 require('lib/pkp/includes/bootstrap.inc.php');
21 
23 $request = $application->getRequest();
24 
25 // FIXME: Write and use a CLIRouter here (see classdoc)
26 import('classes.core.PageRouter');
27 $router = new PageRouter();
28 $router->setApplication($application);
29 $request->setRouter($router);
30 
31 import('classes.template.TemplateManager');
32 import('lib.pkp.classes.form.Form');
33 
34 // Extend the TemplateManager class to:
35 // - access test templates
36 // - adjust $baseUrl to obtain proper paths to application js+css
37 // - prevent the creation of urls from within templates
38 // - modify the initialization procedure,
39 // allowing Form::display() to use FBVTemplateManager
41 
42  function __construct() {
43  parent::__construct();
44 
45  $this->caching = 0;
46 
47  // look for templates in the test directory
48  $baseDir = Core::getBaseDir();
49  $test_template_dir = $baseDir . DIRECTORY_SEPARATOR . PKP_LIB_PATH . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'fbv';
50  $this->template_dir[] = $test_template_dir;
51 
52  // $baseUrl has to be reset to properly reference the javascript files and stylesheets
53  $baseUrl = '';
54  $uriComponents = explode('/', $_SERVER['REQUEST_URI']);
55 
56  for ($i=0, $count=count($uriComponents); $i<$count; $i++) {
57  if ($uriComponents[$i] == 'tools' && $uriComponents[$i+1] == 'fbvVisualResults.php') break;
58  else if (empty($uriComponents[$i])) continue;
59  else $baseUrl .= '/' . $uriComponents[$i];
60  }
61 
62  $this->assign('baseUrl', $baseUrl);
63  }
64 
66  function initialize() {
67  $this->initialized = true;
68  }
69 
71  function &getManager($request = null) {
72  $instance =& Registry::get('templateManager', true, null);
73 
74  if ($instance === null) {
75  $instance = new FBVTemplateManager($request);
76  }
77  return $instance;
78  }
79 
81  function smartyUrl($params, &$smarty) {
82  return null;
83  }
84 }
85 
86 // main class for this tool
88  // constructor: set FBVTemplateManager instance in the registry
89  function __construct() {
91  }
92 
93  // generate the results
94  function execute() {
95  if (isset($_GET['display'])) {
96  switch ($_GET['display']) {
97  case 'modal':
98  $testForm = new Form('fbvTestForm.tpl');
99  break;
100  default:
101  $testForm = new Form('fbvTestFormWrapper.tpl');
102  }
103  } else {
104  $testForm = new Form('fbvTestFormWrapper.tpl');
105  }
106 
107  $testForm->display();
108  }
109 
110 }
111 
112 $tool = new fbvVisualResults();
113 $tool->execute();
114 
115 
$application
$application
Definition: index.php:61
FBVTemplateManager\smartyUrl
smartyUrl($params, &$smarty)
Definition: fbvVisualResults.php:81
fbvVisualResults
Tool that generates a page containing the visual presentation of forms coded with the form builder vo...
Definition: fbvVisualResults.php:87
$tool
$tool
Definition: mergeCoverageReportTool.php:120
FBVTemplateManager\initialize
initialize()
Definition: fbvVisualResults.php:66
FBVTemplateManager\getManager
& getManager($request=null)
Definition: fbvVisualResults.php:71
fbvVisualResults\execute
execute()
Definition: fbvVisualResults.php:94
INDEX_FILE_LOCATION
const INDEX_FILE_LOCATION
Definition: index.php:60
fbvVisualResults\__construct
__construct()
Definition: fbvVisualResults.php:89
FBVTemplateManager\__construct
__construct()
Definition: fbvVisualResults.php:42
FBVTemplateManager
Definition: fbvVisualResults.php:40
TemplateManager
Class for accessing the underlying template engine. Currently integrated with Smarty (from http://sma...
Definition: TemplateManager.inc.php:21
Registry\get
static & get($key, $createIfEmpty=false, $createWithDefault=null)
Definition: Registry.inc.php:35
PageRouter
Class providing OMP-specific page routing.
Definition: PageRouter.inc.php:19
Core\getBaseDir
static getBaseDir()
Definition: Core.inc.php:37
Form
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235