コード例 #1
0
ファイル: Server.php プロジェクト: Dulciane/jaws
 /**
  * Compare eTags
  *
  * @param   string  $serverETag server eTag
  * @return  boolean
  * @access  private
  */
 function _compareEtags($serverETag)
 {
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         if (strcmp($this->ajax->_getServer('HTTP_IF_NONE_MATCH'), $serverETag) == 0) {
             $this->_sendCacheHeaders($serverETag, true);
             return true;
         }
     }
     $this->_sendCacheHeaders($serverETag, false);
     return false;
 }
コード例 #2
0
ファイル: test_speed.php プロジェクト: Ogwang/sainp
/**
 * Simple speed test using the null serializer, possibly useful in comparing overhead when tested on local host
 *
 *
 * @category   HTML
 * @package    AJAX
 * @author     Joshua Eichorn <*****@*****.**>
 * @copyright  2005 Joshua Eichorn
 * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
 * @version    Release: 0.5.6
 * @link       http://pear.php.net/package/HTML_AJAX
 */
include 'HTML/AJAX.php';
include '../support/test.class.php';
$ajax = new HTML_AJAX();
$ajax->serializer = "Null";
$ajax->unserializer = "Null";
$ajax->registerClass(new test());
if ($ajax->handleRequest()) {
    die;
}
?>
<html>
<head>

<script type='text/javascript' src="../server.php?client=all&stub=all"></script>
</head>
<body>
<script type="text/javascript">
var t = new test();
コード例 #3
0
ファイル: bugfixes.php プロジェクト: Ogwang/sainp
/**
 * Simple grab example
 *
 * @category   HTML
 * @package    AJAX
 * @author     Arpad Ray <*****@*****.**>
 * @copyright  2005 Arpad Ray
 * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
 * @version    Release: 0.5.6
 * @link       http://pear.php.net/package/HTML_AJAX
 */
include 'HTML/AJAX.php';
if (isset($_GET['grab'])) {
    die('Grabbed from php!');
}
$ajax = new HTML_AJAX();
if ($ajax->handleRequest()) {
    exit;
}
?>
<html>
<head>
<script type='text/javascript' src="../js/HTML_AJAX.js"></script>
<script type="text/javascript">
var BugFixes = {
    /**
     * @link http://pear.php.net/bugs/11542
     */
    bug11542: function()
    {
        var i = 0;
コード例 #4
0
 * An example debugging event listener is also shown
 *
 * @category   HTML
 * @package    AJAX
 * @author     Joshua Eichorn <*****@*****.**>
 * @copyright  2005 Joshua Eichorn
 * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
 * @version    Release: 0.5.6
 * @link       http://pear.php.net/package/HTML_AJAX
 */
// include the main HTML_AJAX class
include 'HTML/AJAX.php';
// our simple test class
include 'support/test.class.php';
// create an instance of HTML_AJAX
$ajax = new HTML_AJAX();
// register an instance of the test class
$ajax->registerClass(new test());
// handle and ajax call, if one is made die, else continue processing
if ($ajax->handleRequest()) {
    die;
}
?>
<html>
<head>

<!-- the entire client library can be retreived in one call using the all keyword, or each piece can be requested like below -->
<script type='text/javascript' src="server.php?client=Main"></script>
<script type='text/javascript' src="server.php?client=Dispatcher"></script>
<script type='text/javascript' src="server.php?client=HttpClient"></script>
<script type='text/javascript' src="server.php?client=Request"></script>
コード例 #5
0
ファイル: build.php プロジェクト: Dulciane/jaws
/**
 * A simple script to build a single js file from the multiple sources
 * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
 */
// simple script contains a merged js file from multiple source files
// can optionaly strip whitespace
require_once 'HTML/AJAX.php';
$dest = "HTML_AJAX.js";
if (isset($argv[1])) {
    $dest = $argv[1];
}
$strip = false;
if (isset($argv[2]) && $argv[2] == 'strip') {
    $strip = true;
}
$source = array('Compat.js', 'Main.js', 'Queue.js', 'clientPool.js', 'IframeXHR.js', 'serializer/UrlSerializer.js', 'serializer/phpSerializer.js', 'Dispatcher.js', 'HttpClient.js', 'Request.js', 'serializer/JSON.js', 'serializer/haSerializer.js', 'Loading.js', 'util.js', 'behavior/behavior.js', 'behavior/cssQuery-p.js');
$out = '';
$ajax = new HTML_AJAX();
foreach ($source as $file) {
    if ($strip) {
        $s = $ajax->packJavaScript(file_get_contents($file));
    } else {
        $s = file_get_contents($file);
    }
    $out .= "// {$file}\n";
    $out .= $s;
}
$fp = fopen($dest, 'w');
fwrite($fp, $out);
fclose($fp);
コード例 #6
0
ファイル: Server.php プロジェクト: BackupTheBerlios/smart-svn
 /**
  * Generate client js
  *
  * @todo    this is going to need tests to cover all the options
  */
 function generateClient()
 {
     $headers = array();
     ob_start();
     // create a list list of js files were going to need to output
     $fileList = array();
     if (!is_array($this->options['client'])) {
         $this->options['client'] = array();
     }
     foreach ($this->options['client'] as $library) {
         if (isset($this->javascriptLibraries[$library])) {
             $lib = (array) $this->javascriptLibraries[$library];
             foreach ($lib as $file) {
                 if (isset($this->javascriptLibraryPaths[$library])) {
                     $fileList[] = $this->javascriptLibraryPaths[$library] . $file;
                 } else {
                     $fileList[] = $this->clientJsLocation() . $file;
                 }
             }
         }
     }
     // do needed class init if were running an init server
     if (!is_array($this->options['stub'])) {
         $this->options['stub'] = array();
     }
     $classList = $this->options['stub'];
     if ($this->initMethods) {
         if (isset($this->options['stub'][0]) && $this->options['stub'][0] === 'all') {
             $this->_initAll();
         } else {
             foreach ($this->options['stub'] as $stub) {
                 $this->_init($stub);
             }
         }
     }
     if (isset($this->options['stub'][0]) && $this->options['stub'][0] === 'all') {
         $classList = array_keys($this->ajax->_exportedInstances);
     }
     // if were doing stub and client we have to wait for both ETags before we can compare with the client
     $combinedOutput = false;
     if ($classList != false && count($classList) > 0 && count($fileList) > 0) {
         $combinedOutput = true;
     }
     if ($classList != false && count($classList) > 0) {
         // were setup enough to make a stubETag if the input it wants is a class list
         if ($this->cacheOptions['httpCacheStub'] && $this->cacheOptions['StubCacheExpects'] == 'classes') {
             $stubETag = $this->_callCacheRule('Stub', $classList);
         }
         // if were not in combined output compare etags, if method returns true were done
         if (!$combinedOutput && isset($stubETag)) {
             if ($this->_compareEtags($stubETag)) {
                 ob_end_clean();
                 return;
             }
         }
         // output the stubs for all the classes in our list
         foreach ($classList as $class) {
             echo $this->ajax->generateClassStub($class);
         }
         // if were cacheing and the rule expects content make a tag and check it, if the check is true were done
         if ($this->cacheOptions['httpCacheStub'] && $this->cacheOptions['StubCacheExpects'] == 'content') {
             $stubETag = $this->_callCacheRule('Stub', ob_get_contents());
         }
         // if were not in combined output compare etags, if method returns true were done
         if (!$combinedOutput && isset($stubETag)) {
             if ($this->_compareEtags($stubETag)) {
                 ob_end_clean();
                 return;
             }
         }
     }
     if (count($fileList) > 0) {
         // if were caching and need a file list build our jsETag
         if ($this->cacheOptions['httpCacheClient'] && $this->cacheOptions['ClientCacheExpects'] === 'files') {
             $jsETag = $this->_callCacheRule('Client', $fileList);
         }
         // if were not in combined output compare etags, if method returns true were done
         if (!$combinedOutput && isset($jsETag)) {
             if ($this->_compareEtags($jsETag)) {
                 ob_end_clean();
                 return;
             }
         }
         // output the needed client js files
         foreach ($fileList as $file) {
             $this->_readFile($file);
         }
         // if were caching and need content build the etag
         if ($this->cacheOptions['httpCacheClient'] && $this->cacheOptions['ClientCacheExpects'] === 'content') {
             $jsETag = $this->_callCacheRule('Client', ob_get_contents());
         }
         // if were not in combined output compare etags, if method returns true were done
         if (!$combinedOutput && isset($jsETag)) {
             if ($this->_compareEtags($jsETag)) {
                 ob_end_clean();
                 return;
             }
         } else {
             if (isset($jsETag) && isset($stubETag)) {
                 if ($this->_compareEtags(md5($stubETag . $jsETag))) {
                     ob_end_clean();
                     return;
                 }
             }
         }
     }
     // were outputting content, add our length header and send the output
     $length = ob_get_length();
     $output = ob_get_contents();
     ob_end_clean();
     if ($length > 0 && $this->ajax->_sendContentLength()) {
         $headers['Content-Length'] = $length;
     }
     $headers['Content-Type'] = 'text/javascript; charset=utf-8';
     call_user_func($this->ajax->_callbacks['headers'], $headers);
     echo $output;
 }