PHP Classes

File: test/ssa/toEndTest/javascript.php

Recommend this page to a friend!
  Classes of thomas   SSA   test/ssa/toEndTest/javascript.php   Download  
File: test/ssa/toEndTest/javascript.php
Role: Example script
Content type: text/plain
Description: Example script
Class: SSA
Call PHP classes from JavaScript on Web pages
Author: By
Last change: add requirejs support of ssa generator
Date: 9 years ago
Size: 1,043 bytes
 

Contents

Class file image Download
<?php

include 'serviceConfig.php';

use
ssa\converter\AngularJavascriptConverter;
use
ssa\converter\RequireJsJavascriptConverter;
use
ssa\converter\JavascriptConverter;
use
ssa\converter\SimpleUrlFactory;

// get base url for generic javascript generator
// if you know your base url you can remove three next lines
$serverRequestURI = $_SERVER['REQUEST_URI'];
$startUrl = substr($serverRequestURI, 0, strrpos($serverRequestURI, '?'));
$url = substr($startUrl,0, strrpos($startUrl, '/'));

// create an url factory used for call webservice
$factory = new SimpleUrlFactory("http://$_SERVER[HTTP_HOST]$url/run.php?service={action}&test=true");
if (isset(
$_GET['type']) && $_GET['type'] === 'angular') {
   
$converter = new AngularJavascriptConverter($_GET['service'], $factory);
} else if (isset(
$_GET['type']) && $_GET['type'] === 'requirejs') {
   
$converter = new RequireJsJavascriptConverter(trim($_GET['service'], '/'), $factory);
} else {
   
$converter = new JavascriptConverter($_GET['service'], $factory);
}
echo
$converter->convert();