• Main Page
  • Modules
  • Classes
  • Files
  • File List

tools/fbvVisualResults.php

00001 <?php
00002 
00017 define('INDEX_FILE_LOCATION', dirname(dirname(__FILE__)) . '/index.php');
00018 chdir(dirname(INDEX_FILE_LOCATION)); /* Change to base directory */
00019 require('lib/pkp/includes/bootstrap.inc.php');
00020 
00021 $application =& PKPApplication::getApplication();
00022 $request =& $application->getRequest();
00023 
00024 // FIXME: Write and use a CLIRouter here (see classdoc)
00025 import('classes.core.PageRouter');
00026 $router = new PageRouter();
00027 $router->setApplication($application);
00028 $request->setRouter($router);
00029 
00030 import('classes.template.TemplateManager');
00031 import('lib.pkp.classes.form.Form');
00032 
00033 // Extend the TemplateManager class to:
00034 // - access test templates
00035 // - adjust $baseUrl to obtain proper paths to application js+css
00036 // - prevent the creation of urls from within templates
00037 // - modify the initialization procedure,
00038 //      allowing Form::display() to use FBVTemplateManager
00039 class FBVTemplateManager extends TemplateManager {
00040 
00041    function FBVTemplateManager() {
00042       parent::TemplateManager();
00043 
00044       $this->caching = 0;
00045 
00046       // look for templates in the test directory
00047       $baseDir = Core::getBaseDir();
00048       $test_template_dir = $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'ui' . DIRECTORY_SEPARATOR . 'fbv';
00049       $this->template_dir[] = $test_template_dir;
00050 
00051       // $baseUrl has to be reset to properly reference the javascript files and stylesheets
00052       $baseUrl = '';
00053       $uriComponents = explode('/', $_SERVER['REQUEST_URI']);
00054 
00055       for ($i=0, $count=count($uriComponents); $i<$count; $i++) {
00056          if ($uriComponents[$i] == 'tools' && $uriComponents[$i+1] == 'fbvVisualResults.php') break;
00057          else if (empty($uriComponents[$i])) continue;
00058          else $baseUrl .= '/' . $uriComponents[$i];
00059       }
00060 
00061       $this->assign('baseUrl', $baseUrl);
00062    }
00063 
00065    function initialize() {
00066       $this->initialized = true;
00067    }
00068 
00070    function &getManager($request = null) {
00071       $instance =& Registry::get('templateManager', true, null);
00072 
00073       if ($instance === null) {
00074          $instance = new FBVTemplateManager($request);
00075       }
00076       return $instance;
00077    }
00078 
00080    function smartyUrl($params, &$smarty) {
00081       return null;
00082    }
00083 }
00084 
00085 // main class for this tool
00086 class fbvVisualResults {
00087    // constructor: set FBVTemplateManager instance in the registry
00088    function fbvVisualResults() {
00089       FBVTemplateManager::getManager();
00090    }
00091 
00092    // generate the results
00093    function execute() {
00094       if (isset($_GET['display'])) {
00095          switch ($_GET['display']) {
00096             case 'modal':
00097                $testForm = new Form('fbvTestForm.tpl');
00098                break;
00099             default:
00100                $testForm = new Form('fbvTestFormWrapper.tpl');
00101          }
00102       } else {
00103          $testForm = new Form('fbvTestFormWrapper.tpl');
00104       }
00105 
00106       $testForm->display();
00107    }
00108 
00109 }
00110 
00111 $tool = new fbvVisualResults();
00112 $tool->execute();
00113 
00114 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1