/usr/share/php/xajax/tests/basicPluginTest.php is in php-xajax 0.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | <?php
$core = dirname(dirname(__FILE__)) . '/xajax_core';
require_once $core . '/xajax.inc.php';
$xajax = new xajax();
//$xajax->configure('debug', true);
$xajax->configure('javascript URI', '../');
require_once $core . '/xajaxPlugin.inc.php';
require_once $core . '/xajaxPluginManager.inc.php';
class testPlugin extends xajaxResponsePlugin
{
var $sDefer;
function testPlugin()
{
$this->sDefer = '';
}
function getName()
{
return 'testPlugin';
}
function generateClientScript()
{
echo "\n<script type='text/javascript' " . $this->sDefer . "charset='UTF-8'>\n";
echo "/* <![CDATA[ */\n";
echo "xajax.command.handler.register('testPlg', function(args) { \n";
echo "\talert('Test plugin command received: ' + args.data);\n";
echo "});\n";
echo "/* ]]> */\n";
echo "</script>\n";
}
function testMethod()
{
$this->addCommand(array('n'=>'testPlg'), 'abcde]]>fg');
}
}
$objPluginManager = &xajaxPluginManager::getInstance();
$objPluginManager->registerPlugin(new testPlugin());
function showOutput()
{
$testResponse = new xajaxResponse();
$testResponse->alert("Edit this test and uncomment lines in the showOutput() method to test plugin calling");
// PHP4 & PHP5
$testResponse->plugin("testPlugin", "testMethod");
// PHP5 ONLY - Uncomment to test
//$testResponse->plugin("testPlugin")->testMethod();
// PHP5 ONLY - Uncomment to test
//$testResponse->testPlugin->testMethod();
$testResponseOutput = htmlspecialchars($testResponse->getOutput());
$objResponse = new xajaxResponse();
$objResponse->assign("submittedDiv", "innerHTML", $testResponseOutput);
$objResponse->plugin('testPlugin', 'testMethod');
return $objResponse;
}
$reqShowOutput =& $xajax->register(XAJAX_FUNCTION, "showOutput");
$xajax->processRequest();
include_once($core . '/xajaxControl.inc.php');
$controls = dirname(dirname(__FILE__)) . '/xajax_controls';
include_once($controls . '/content.inc.php');
include_once($controls . '/misc.inc.php');
$buttonShowOutput = new clsButton(array(
'attributes' => array(
'id' => 'btnShowOutput',
'name' => 'btnShowOutput'
),
'children' => array(
new clsLiteral('Show Response XML')
)
));
$buttonShowOutput->setEvent('onclick', $reqShowOutput);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Basic Plugin Test | xajax Tests</title>
<?php $xajax->printJavascript() ?>
</head>
<body>
<h2><a href="index.php">xajax Tests</a></h2>
<h1>Basic Plugin Test</h1>
<form id="testForm1" onsubmit="return false;">
<p><?php $buttonShowOutput->printHTML(); ?></p>
</form>
<div id="submittedDiv"></div>
</body>
</html>
|