예제 #1
0
 /**
  * Enter description here...
  *
  * @param \PhpQuery\PhpQueryObject $self
  * @param                          $arg1
  * @return null|\PhpQuery\PhpQueryObject
  */
 public static function script($self, $arg1)
 {
     $params = func_get_args();
     $params = array_slice($params, 2);
     $return = null;
     $config = self::$config;
     if (\PhpQuery\Plugin\UtilScripts::$scriptMethods[$arg1]) {
         PhpQuery::callbackRun(\PhpQuery\Plugin\UtilScripts::$scriptMethods[$arg1], array($self, $params, &$return, $config));
     } else {
         if ($arg1 != '__config' && file_exists(dirname(__FILE__) . "/Scripts/{$arg1}.php")) {
             PhpQuery::debug("Loading script '{$arg1}'");
             require dirname(__FILE__) . "/Scripts/{$arg1}.php";
         } else {
             PhpQuery::debug("Requested script '{$arg1}' doesn't exist");
         }
     }
     return $return ? $return : $self;
 }
예제 #2
0
 /**
  * Binds a handler to one or more events (like click) for each matched element.
  * Can also bind custom events.
  *
  * @param \DOMNode|PhpQueryObject|string $document
  * @param                                $node
  * @param string                         $type
  * @param string                         $data Optional
  * @param                                $callback
  *
  * @TODO support '!' (exclusive) events
  * @TODO support more than event in $type (space-separated)
  * @TODO support binding to global events
  */
 public static function add($document, $node, $type, $data, $callback = null)
 {
     PhpQuery::debug("Binding '{$type}' event");
     $documentID = PhpQuery::getDocumentID($document);
     //		if (is_null($callback) && is_callable($data)) {
     //			$callback = $data;
     //			$data = null;
     //		}
     $eventNode = self::getNode($documentID, $node);
     if (!$eventNode) {
         $eventNode = self::setNode($documentID, $node);
     }
     if (!isset($eventNode->eventHandlers[$type])) {
         $eventNode->eventHandlers[$type] = array();
     }
     $eventNode->eventHandlers[$type][] = array('callback' => $callback, 'data' => $data);
 }
예제 #3
0
 public static function debug($text)
 {
     phpQuery::debug($text);
 }
예제 #4
0
 public function dumpTree($html = true, $title = true)
 {
     $output = $title ? 'DUMP #' . PhpQuery::$dumpCount++ . " \n" : '';
     $debug = PhpQuery::$debug;
     PhpQuery::$debug = false;
     foreach ($this->stack() as $node) {
         $output .= $this->__dumpTree($node);
     }
     PhpQuery::$debug = $debug;
     print $html ? nl2br(str_replace(' ', ' ', $output)) : $output;
     return $this;
 }
예제 #5
0
 /**
  * @param Zend_Http_Client $xhr
  */
 public static function browserDownload($xhr)
 {
     PhpQuery::debug("[WebBrowser] Received from " . $xhr->getUri(true));
     // TODO handle meta redirects
     $body = $xhr->getLastResponse()->getBody();
     return $body;
 }