plugin() public static méthode

Extend phpQuery with $class from $file.
public static plugin ( string $class, string $file = null )
$class string Extending class name. Real class name can be prepended phpQuery_.
$file string Filename to include. Defaults to "{$class}.php".
Exemple #1
0
<?php

/**
 * Automated google account login.
 * Uses __config.php to keep login data.
 *
 * @package phpQuery.Plugins.Scripts
 * @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
 */
phpQuery::ajaxAllowHost('code.google.com', 'google.com', 'www.google.com', 'mail.google.com', 'docs.google.com', 'reader.google.com');
if (!function_exists('ndfasui8923')) {
    function ndfasui8923($browser, $scope)
    {
        extract($scope);
        $browser->WebBrowser()->find('#Email')->val($config['google_login'][0])->end()->find('#Passwd')->val($config['google_login'][1])->parents('form')->submit();
    }
    $ndfasui8923 = new Callback('ndfasui8923', new CallbackParam(), compact('config', 'self', 'return', 'params'));
}
phpQuery::plugin('WebBrowser');
$self->document->xhr = phpQuery::$plugins->browserGet('https://www.google.com/accounts/Login', $ndfasui8923);
//$self->document->xhr = phpQuery::$plugins->browserGet('https://www.google.com/accounts/Login', create_function('$browser', "
//	\$browser
//		->WebBrowser()
//		->find('#Email')
//			->val('{$config['google_login'][0]}')->end()
//		->find('#Passwd')
//			->val('".str_replace("'", "\\'", $config['google_login'][1])."')
//			->parents('form')
//				->submit();"
//));
Exemple #2
0
<?php

//error_reporting(E_ALL);
require_once '../phpQuery/phpQuery.php';
phpQuery::$debug = true;
phpQuery::plugin('Scripts');
$testName = 'Scripts/example';
$doc = phpQuery::newDocumentFile('test.html');
$testResult = 10;
if ($doc->script('example', 'p')->length == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print "<pre>";
    var_dump($doc->whois());
    print "</pre>\n";
}
print "\n";
$testName = 'Scripts/gmail_login';
$testResult = 1;
$url = 'http://code.google.com/p/phpquery/w/edit/MultiDocumentSupport';
//phpQuery::ajaxAllowURL($url);
$editor = phpQuery::newDocument('<div/>')->script('google_login')->location($url);
if ($editor->find('textarea#content')->length == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print "<pre>";
    var_dump($doc->whois());
    print "</pre>\n";
}
Exemple #3
0
 /**
  * Enter description here...
  *
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  */
 public function plugin($class, $file = null)
 {
     phpQuery::plugin($class, $file);
     return $this;
 }
        $pq->WebBrowser('success2')->find('input[name=q]')->val('phpQuery')->parents('form')->submit();
    }
    /**
     *
     * @param $html phpQueryObject
     * @return unknown_type
     */
    function success2($pq)
    {
        print 'success2 callback';
        print $pq->find('script')->remove()->end();
    }
}
// Gmail login (not working...)
if (0) {
    phpQuery::plugin("Scripts");
    phpQuery::newDocument('<div/>')->script('google_login')->location('http://mail.google.com/')->toReference($pq);
    if ($pq) {
        print $pq->script('print_websafe');
    }
}
// Gmail login v2 (not working...)
if (0) {
    $browser = null;
    $browserCallback = new CallbackReference($browser);
    phpQuery::browserGet('http://mail.google.com/', $browserCallback);
    if ($browser) {
        $browser->WebBrowser($browserCallback)->find('#Email')->val('*****@*****.**')->end()->find('#Passwd')->val('XXX')->parents('form')->submit();
        if ($browser) {
            print $browser->script('print_websafe');
        }