예제 #1
0
 public function testExtend()
 {
     $newMethods = array('newMethod1' => array($this, 'callback1'), 'newMethod2' => array($this, 'callback2'));
     PhpQuery::extend('PhpQueryObject', $newMethods);
     $doc = PhpQuery::newDocumentXML("<div/>");
     $this->assertTrue($doc->newMethod1() == $doc, '$doc->newMethod1 == $doc');
     $this->assertTrue($doc->newMethod2() == "callback2", '$doc->newMethod1 == "callback2"');
 }
예제 #2
0
<?php

require_once '../PhpQuery/PhpQuery.php';
PhpQuery::$debug = true;
PhpQuery::extend('WebBrowser');
PhpQuery::$ajaxAllowedHosts[] = 'gmail.com';
PhpQuery::$ajaxAllowedHosts[] = 'google.com';
PhpQuery::$ajaxAllowedHosts[] = 'www.google.com';
PhpQuery::$ajaxAllowedHosts[] = 'www.google.pl';
PhpQuery::$ajaxAllowedHosts[] = 'mail.google.com';
// Google search results
if (0) {
    PhpQuery::$plugins->browserGet('http://google.com/', 'success1');
    /**
     *
     * @param $pq PhpQueryObject
     * @return unknown_type
     */
    function success1($pq)
    {
        print 'success1 callback';
        $pq->WebBrowser('success2')->find('input[name=q]')->val('PhpQuery')->parents('form')->submit();
    }
    /**
     *
     * @param $html PhpQueryObject
     * @return unknown_type
     */
    function success2($pq)
    {
        print 'success2 callback';